package org.jeecg.modules.ParameterModule.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.ParameterModule.entity.*;
import org.jeecg.modules.ParameterModule.mapper.*;
import org.jeecg.modules.ParameterModule.service.AgainEnabledService;
import org.jeecg.modules.ParameterModule.service.CategoryInfoService;
import org.jeecg.modules.ParameterModule.service.FormalPlateInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Random;
import java.util.UUID;

@Service
public class AgainEnabledServiceImpl extends ServiceImpl<AgainEnabledMapper, MlccCategoryInfo> implements AgainEnabledService {
    @Autowired
    private AgainEnabledMapper againEnabledMapper;//再次启用
    @Autowired
    private FormalCategoryInfoMapper formalCategoryInfoMapper;//品类的正式
    @Autowired
    private CategoryInfoMapper categoryInfoMapper;//测试的品类
    @Autowired
    private TestPlateInfoMapper testPlateInfoMapper;//测试版号
    @Autowired
    private FormalPlateInfoMapper formalPlateInfoMapper;//正式版号

    /**
     * 启用草稿件
     *
     * @param category_id 测试品类ID
     */
    @Override
    public int enabled_category_caogao(String category_id) {
        //获取登录用户信息
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String sys_org_code = sysUser.getOrgCode();
        String create_by = sysUser.getUsername();
        //声明正式的品类id和名称
        String zhengshi_categoryId = "", zhengshi_categoryName = "";
        //根据测试品类id查询品类
        MlccCategoryTestInfo testcategoryDetail = againEnabledMapper.query_categoryDetailByid(category_id);
        String issize = testcategoryDetail.getIsSize().toString();
        MlccCategoryInfo zsCategoryDetail = againEnabledMapper.select_zscategoryDetail(testcategoryDetail.getCategoryCode());
        if (zsCategoryDetail != null) {//再次启用
            //先判断该品类是否上架
            if (zsCategoryDetail.getStatus() == 0) {
                return 2;//请先下架再启用
            } else {
                int code2 = 0, code3 = 0, code4 = 0, code5 = 0, code6 = 0, code7 = 0, code8 = 0, code9 = 0, code10 = 0, code66 = 0, code11 = 0, code67 = 0, code12;
                Long startTs1 = System.currentTimeMillis(); // 当前时间戳
                /**正式品类id下的参数*/
                String formalcategory_id = zsCategoryDetail.getId().toString();
                zhengshi_categoryName = zsCategoryDetail.getCategoryName();
                //根据测试品类id查询所有的数据
                //根据品类id查询定制项
                List<SmalltemplateTestInfo> dingzhilist = againEnabledMapper.query_dingzhiBytopId(category_id);
                //根据品类id查询定制项下的参数
                List<MlccCategoryTestInfo> canshulist = againEnabledMapper.query_dingzhi_canshuBytopId(category_id);
                //根据品类id查询互斥项
                List<MutexTestInfo> huchilist = againEnabledMapper.query_mutextBytopId(category_id);
                //根据品类id查询绣字部位
                List<CategoryLocationTestInfo> xuzilist1 = againEnabledMapper.query_LocationBytopId(category_id);
                //根据品类id查询绣字颜色
                List<EmbroideredColorTestInfo> xuzilist2 = againEnabledMapper.query_EmbroideredColorBytopId(category_id);
                //根据品类id查询绣字图片
                List<EmbroideredFontTestInfo> xuzilist3 = againEnabledMapper.query_EmbroideredFontBytopId(category_id);
                //根据品类id查询撞色
                List<ContrastcolorTestInfo> zhuangselist = againEnabledMapper.query_ContrastcolorBytopId(category_id);
                //根据品类id查询净体尺寸
                List<BodySizeTestInfo> bodysizelist1 = againEnabledMapper.query_BodySizeBytopId(category_id);
                //根据品类id查询返修
                List<CategoryFanxiuTestInfo> fanxiulist = againEnabledMapper.query_CategoryFanxiuBytopId(category_id);
                //根据品类id查询工艺类型
                List<MlccCategoryTestInfo> gongyilist = againEnabledMapper.query_MlccCategoryBytopId(category_id);
                //根据品类id查询所有系统加急
                List<AddSystemPriceInfo> syspricelist = againEnabledMapper.query_AddSystemPriceBytopId(category_id, 1);
                List<AddSystemPriceInfo> syspricelist2 = againEnabledMapper.query_AddSystemPriceBytopId(category_id, 0);
                //根据品类id查询所有绣字高度-测试
                List<EmbroidedHeightInfo> xiuziHeightlist = againEnabledMapper.query_EmbroidedHeightBytopId(category_id);

                if (dingzhilist.size() > 0) {
                    for (int i = 0; i < dingzhilist.size(); i++) {
                        if (dingzhilist.get(i).getStatus() != 0) {//假删除
                            //根据编号删除正式的定制项
                            code2 = againEnabledMapper.delete_zsDingzhiByCodeplate(dingzhilist.get(i).getCode(), formalcategory_id);
                            System.out.println("删除定制项成功==" + code2);
                            //根据品类id和编号查询当前没有删除的数据--仅仅只有一个
                            SmalltemplateTestInfo zs_datadetail = againEnabledMapper.query_dingzhitailByCode(dingzhilist.get(i).getCode(),category_id,3);
                            if(zs_datadetail!=null){
                                //执行添加
                                SmalltemplateTestInfo datainfo = new SmalltemplateTestInfo();
                                datainfo.setModuleId(zs_datadetail.getModuleId());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setCode(zs_datadetail.getCode());
                                datainfo.setParameter(zs_datadetail.getParameter());
                                datainfo.setImgs(zs_datadetail.getImgs());
                                datainfo.setNumbers(zs_datadetail.getNumbers());
                                datainfo.setIstype(zs_datadetail.getIstype());
                                datainfo.setRemark(zs_datadetail.getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code2 = formalCategoryInfoMapper.add_dingzhi(datainfo);
                            }
                        } else {//没删
                            //根据编号查询正式的定制项有没有，如果有就执行修改，没有就执行添加
                            SmalltemplateTestInfo zsdingzhiDetail = againEnabledMapper.query_zsDingzhiDetailByCodeplate(dingzhilist.get(i).getCode(), formalcategory_id);
                            if (zsdingzhiDetail != null) {
                                //执行修改
                                SmalltemplateTestInfo datainfo = new SmalltemplateTestInfo();
                                datainfo.setCode(dingzhilist.get(i).getCode());
                                datainfo.setParameter(dingzhilist.get(i).getParameter());
                                datainfo.setNumbers(dingzhilist.get(i).getNumbers());
                                datainfo.setRemark(dingzhilist.get(i).getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setUpdateBy(create_by);
                                datainfo.setId(zsdingzhiDetail.getId());
                                code2 = formalCategoryInfoMapper.change_dingzhi(datainfo);
                            } else {
                                //执行添加
                                SmalltemplateTestInfo datainfo = new SmalltemplateTestInfo();
                                datainfo.setModuleId(dingzhilist.get(i).getModuleId());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setCode(dingzhilist.get(i).getCode());
                                datainfo.setParameter(dingzhilist.get(i).getParameter());
                                datainfo.setImgs(dingzhilist.get(i).getImgs());
                                datainfo.setNumbers(dingzhilist.get(i).getNumbers());
                                datainfo.setIstype(dingzhilist.get(i).getIstype());
                                datainfo.setRemark(dingzhilist.get(i).getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code2 = formalCategoryInfoMapper.add_dingzhi(datainfo);
                            }
                        }
                    }
                }
                /**
                 * 定制项下的参数
                 */
                if (canshulist.size() > 0) {
                    for (int i = 0; i < canshulist.size(); i++) {
                        if (canshulist.get(i).getStatus() != 0) {//假删除
                            String praent_id = "";//获取他的上级
                            SmalltemplateTestInfo ceshidingdatainfo = categoryInfoMapper.query_dingzhiBydingzhId(canshulist.get(i).getParentId());
                            if (ceshidingdatainfo != null) {
                                //查询新增的定制项
                                List<SmalltemplateTestInfo> zsdingzhi_datalist = formalCategoryInfoMapper.query_dingzhiBycategoryId(formalcategory_id);
                                if (zsdingzhi_datalist.size() > 0) {
                                    for (int k = 0; k < zsdingzhi_datalist.size(); k++) {
                                        if (ceshidingdatainfo.getCode().equals(zsdingzhi_datalist.get(k).getCode())) {
                                            praent_id = zsdingzhi_datalist.get(k).getId().toString();
                                        }
                                    }
                                }
                            }
                            //根据编号和上级id删除正式的定制项下的参数
                            code3 = againEnabledMapper.delete_zsDingzhi_canshuByCode(canshulist.get(i).getCategoryCode(), praent_id, formalcategory_id);
                            System.out.println("删除成功==" + code3);
                            //根据品类id和编号查询当前没有删除的数据--仅仅只有一个
                            MlccCategoryTestInfo zs_datadetail = againEnabledMapper.query_dingzhi_canshutailByCode2(canshulist.get(i).getCategoryCode(),category_id,canshulist.get(i).getParentId());
                            if(zs_datadetail!=null){
                                String praent_id2 = "";//获取他的上级
                                SmalltemplateTestInfo ceshidingdatainfo2 = categoryInfoMapper.query_dingzhiBydingzhId(zs_datadetail.getParentId());
                                if (ceshidingdatainfo2 != null) {
                                    //查询新增的定制项
                                    List<SmalltemplateTestInfo> zsdingzhi_datalist = formalCategoryInfoMapper.query_dingzhiBycategoryId(formalcategory_id);
                                    if (zsdingzhi_datalist.size() > 0) {
                                        for (int k = 0; k < zsdingzhi_datalist.size(); k++) {
                                            if (ceshidingdatainfo.getCode().equals(zsdingzhi_datalist.get(k).getCode())) {
                                                praent_id2 = zsdingzhi_datalist.get(k).getId().toString();
                                            }
                                        }
                                    }
                                }
                                System.out.println("走的添加参数111==="+praent_id2+"==="+formalcategory_id);
                                //执行添加
                                MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                                datainfo.setCategoryName(zs_datadetail.getCategoryName());
                                datainfo.setCategoryCode(zs_datadetail.getCategoryCode());
                                datainfo.setParentId(praent_id2);//正式的上级id
                                datainfo.setImg(zs_datadetail.getImg());
                                datainfo.setTopid(formalcategory_id);
                                datainfo.setNumbers(zs_datadetail.getNumbers());
                                datainfo.setIsType(0);
                                datainfo.setCost("0");
                                datainfo.setTeamPrice2("0");
                                datainfo.setStatus(0);
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code3 = formalCategoryInfoMapper.add_dingzhi_canshu(datainfo);
                            }

                        } else {//没删
                            String praent_id3 = "";//获取他的上级
                            SmalltemplateTestInfo ceshidingdatainfo = categoryInfoMapper.query_dingzhiBydingzhId(canshulist.get(i).getParentId());
                            if (ceshidingdatainfo != null) {
                                //查询新增的定制项
                                List<SmalltemplateTestInfo> zsdingzhi_datalist3 = formalCategoryInfoMapper.query_dingzhiBycategoryId(formalcategory_id);
                                if (zsdingzhi_datalist3.size() > 0) {
                                    for (int k = 0; k < zsdingzhi_datalist3.size(); k++) {
                                        if (ceshidingdatainfo.getCode().equals(zsdingzhi_datalist3.get(k).getCode())) {
                                            praent_id3 = zsdingzhi_datalist3.get(k).getId().toString();
                                        }
                                    }
                                }
                            }
                            //根据编号查询正式的定制项有没有，如果有就执行修改，没有就执行添加
                            MlccCategoryInfo zscanshuDetail = againEnabledMapper.query_zscanshuDetailByCode(canshulist.get(i).getCategoryCode(), praent_id3, formalcategory_id);
                            if (zscanshuDetail != null) {
                                //执行修改
                                System.out.println("走的修改参数==="+praent_id3+"==="+formalcategory_id);
                                MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                                datainfo.setCategoryName(canshulist.get(i).getCategoryName());
                                datainfo.setCategoryCode(canshulist.get(i).getCategoryCode());
                                datainfo.setParentId(praent_id3);//正式的上级id
                                datainfo.setImg(canshulist.get(i).getImg());
                                datainfo.setTopid(formalcategory_id);
                                datainfo.setNumbers(canshulist.get(i).getNumbers());
                                datainfo.setIsType(0);
                                datainfo.setStatus(0);
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setUpdateBy(create_by);
                                datainfo.setId(zscanshuDetail.getId());
                                code3 = formalCategoryInfoMapper.change_dingzhi_canshu(datainfo);
                            } else {
                                System.out.println("走的添加参数啊==="+praent_id3+"==="+formalcategory_id);
                                //执行添加
                                MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                                datainfo.setCategoryName(canshulist.get(i).getCategoryName());
                                datainfo.setCategoryCode(canshulist.get(i).getCategoryCode());
                                datainfo.setParentId(praent_id3);//正式的上级id
                                datainfo.setImg(canshulist.get(i).getImg());
                                datainfo.setTopid(formalcategory_id);
                                datainfo.setNumbers(canshulist.get(i).getNumbers());
                                datainfo.setIsType(0);
                                datainfo.setCost("0");
                                datainfo.setTeamPrice2("0");
                                datainfo.setStatus(0);
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code3 = formalCategoryInfoMapper.add_dingzhi_canshu(datainfo);
                            }
                        }
                    }
                }
                /**
                 * 品类下的互斥
                 */
                if (huchilist.size() > 0) {
                    //执行先删除下面所有互斥
//                    againEnabledMapper.delete_zshuchiByTopId(formalcategory_id);
                    for (int i = 0; i < huchilist.size(); i++) {
                        if (huchilist.get(i).getStatus() == 3) {//假删除
                            //根据编号和上级id删除正式的定制项下的参数
                            code4 = againEnabledMapper.delete_zshuchiByCodeplate(huchilist.get(i).getCode(), formalcategory_id);
                            System.out.println("删除互斥成功==" + code4);
                        } else {//没删
                            //查询新增的定制项
                            String dingzhi1 = "", dingzhi2 = "";
                            String firstId = "", secoundId = "";
                            List<SmalltemplateTestInfo> zsdingzhi_datalist = formalCategoryInfoMapper.query_dingzhiBycategoryId(formalcategory_id);
                            SmalltemplateTestInfo ceshidingdatainfo1 = categoryInfoMapper.query_dingzhiBydingzhId(huchilist.get(i).getDingzhi1());
                            SmalltemplateTestInfo ceshidingdatainfo2 = categoryInfoMapper.query_dingzhiBydingzhId(huchilist.get(i).getDingzhi2());
                            if (ceshidingdatainfo1 != null) {
                                if (zsdingzhi_datalist.size() > 0) {
                                    for (int k = 0; k < zsdingzhi_datalist.size(); k++) {
                                        if (ceshidingdatainfo1.getCode().equals(zsdingzhi_datalist.get(k).getCode())) {
                                            dingzhi1 = zsdingzhi_datalist.get(k).getId().toString();
                                            break;
                                        }
                                    }
                                }
                            }
                            if (ceshidingdatainfo2 != null) {
                                if (zsdingzhi_datalist.size() > 0) {
                                    for (int k = 0; k < zsdingzhi_datalist.size(); k++) {
                                        if (ceshidingdatainfo2.getCode().equals(zsdingzhi_datalist.get(k).getCode())) {
                                            dingzhi2 = zsdingzhi_datalist.get(k).getId().toString();
                                            break;
                                        }
                                    }
                                }
                            }
                            //根据类别id查询类别详情
                            MlccCategoryTestInfo leibiedatainfo1 = categoryInfoMapper.select_testcategoryDetail(huchilist.get(i).getCategoryId());
                            if (leibiedatainfo1 != null) {
                                MlccCategoryInfo zsleibie = formalCategoryInfoMapper.select_zscategoryDetailByother(leibiedatainfo1.getCategoryCode(), formalcategory_id, dingzhi1);
                                if (zsleibie != null) {
                                    firstId = zsleibie.getId().toString();
                                }
                            }
                            String canshuids[] = huchilist.get(i).getCategoryOther().split(",");
                            String strbody = "";
                            for (String s : canshuids) {
                                //根据类别id查询类别详情
                                MlccCategoryTestInfo leibiedatainfo2 = categoryInfoMapper.select_testcategoryDetail(s);
                                if (leibiedatainfo2 != null) {
                                    MlccCategoryInfo zsleibie = formalCategoryInfoMapper.select_zscategoryDetailByother(leibiedatainfo2.getCategoryCode(), formalcategory_id, dingzhi2);
                                    if (zsleibie != null) {
                                        strbody += zsleibie.getId().toString() + ",";
                                    }
                                }
                            }
                            if(strbody==null || "".equals(strbody)){
                                secoundId = "";
                            }else {
                                secoundId = strbody.substring(0,strbody.length()-1);
                            }

                            //根据编号查询正式的定制项有没有，如果有就执行修改，没有就执行添加
                            MutexTestInfo zscanshuDetail = againEnabledMapper.query_zshuchiByCode(huchilist.get(i).getCode(), formalcategory_id);
                            if (zscanshuDetail != null) {
                                //循环修改互斥
                                MutexTestInfo datainfo = new MutexTestInfo();
                                datainfo.setMutexName(huchilist.get(i).getMutexName());
                                datainfo.setCategoryId(firstId);//第一个参数id
                                datainfo.setCategoryOther(secoundId);//第二个参数id
                                datainfo.setMutexReason(huchilist.get(i).getMutexReason());
                                datainfo.setStatus(huchilist.get(i).getStatus());
                                datainfo.setDingzhi1(dingzhi1);
                                datainfo.setDingzhi2(dingzhi2);
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setUpdateBy(create_by);
                                datainfo.setId(zscanshuDetail.getId());
                                code4 = againEnabledMapper.change_zshuchiById(datainfo);
                            } else {
                                //循环添加互斥
                                MutexTestInfo datainfo = new MutexTestInfo();
                                datainfo.setMutexName(huchilist.get(i).getMutexName());
                                datainfo.setTopId(formalcategory_id);
                                datainfo.setCategoryId(firstId);//第一个参数id
                                datainfo.setCategoryOther(secoundId);//第二个参数id
                                datainfo.setMutexReason(huchilist.get(i).getMutexReason());
                                datainfo.setStatus(huchilist.get(i).getStatus());
                                datainfo.setCode(huchilist.get(i).getCode());
                                datainfo.setDingzhi1(dingzhi1);
                                datainfo.setDingzhi2(dingzhi2);
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code4 = formalCategoryInfoMapper.add_huchi(datainfo);
                            }
                        }
                    }
                }

                if (xuzilist1.size() > 0) {
                    //先执行根据正式品类id删除全部
//                    againEnabledMapper.delete_zs_xiuzilocaltionByTopId(formalcategory_id);
                    for (int i = 0; i < xuzilist1.size(); i++) {
                        if (xuzilist1.get(i).getStatus() != 0) {//假删除
                            //根据编号删除正式的绣字部位
                            code5 = againEnabledMapper.delete_zsxiuziLocationByCodeplate(xuzilist1.get(i).getCode(), formalcategory_id);
                            System.out.println("删除成功==" + code5);
                            //根据品类id和编号查询当前没有删除的数据--仅仅只有一个
                            CategoryLocationTestInfo zs_datadetail = againEnabledMapper.query_xiuzibuweietailByCode(xuzilist1.get(i).getCode(),category_id,3);
                            if(zs_datadetail!=null){
                                //执行添加
                                CategoryLocationTestInfo datainfo = new CategoryLocationTestInfo();
                                datainfo.setCode(zs_datadetail.getCode());
                                datainfo.setXiuziLocaltion(zs_datadetail.getXiuziLocaltion());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setRemark(zs_datadetail.getRemark());
                                datainfo.setNumbers(zs_datadetail.getNumbers());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                datainfo.setStatus(0);
                                code5 = formalCategoryInfoMapper.add_xiuzi_location(datainfo);
                            }
                        } else {//没删
                            //根据编号查询正式的绣字部位有没有，如果有就执行修改，没有就执行添加
                            CategoryLocationTestInfo zsdingzhiDetail = againEnabledMapper.query_zsxiuziLocationByCode(xuzilist1.get(i).getCode(), formalcategory_id);
                            if (zsdingzhiDetail != null) {
                                //循环修改绣字部位
                                CategoryLocationTestInfo datainfo = new CategoryLocationTestInfo();
//                                datainfo.setCode(xuzilist1.get(i).getCode());
                                datainfo.setXiuziLocaltion(xuzilist1.get(i).getXiuziLocaltion());
                                datainfo.setRemark(xuzilist1.get(i).getRemark());
                                datainfo.setNumbers(xuzilist1.get(i).getNumbers());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setUpdateBy(create_by);
                                datainfo.setId(zsdingzhiDetail.getId());
                                code5 = againEnabledMapper.change_zsxiuziLocationById(datainfo);
                            } else {
                                //循环添加绣字部位
                                CategoryLocationTestInfo datainfo = new CategoryLocationTestInfo();
                                datainfo.setCode(xuzilist1.get(i).getCode());
                                datainfo.setXiuziLocaltion(xuzilist1.get(i).getXiuziLocaltion());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setRemark(xuzilist1.get(i).getRemark());
                                datainfo.setNumbers(xuzilist1.get(i).getNumbers());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code5 = formalCategoryInfoMapper.add_xiuzi_location(datainfo);
                            }
                        }

                    }
                }
                if (xuzilist2.size() > 0) {
                    //先执行根据正式品类id删除全部
//                    againEnabledMapper.delete_zs_xiuzicolorByTopId(formalcategory_id);
                    for (int i = 0; i < xuzilist2.size(); i++) {
                        if (xuzilist2.get(i).getStatus() != 0) {//假删除
                            //根据编号删除正式的绣字部位
                            code6 = againEnabledMapper.delete_zsxiuziColorByCodeplate(xuzilist2.get(i).getCode(), formalcategory_id);
                            System.out.println("删除成功==" + code6);
                            //根据品类id和编号查询当前没有删除的数据--仅仅只有一个
                            EmbroideredColorTestInfo zs_datadetail = againEnabledMapper.query_xiuziColortailByCode(xuzilist2.get(i).getCode(),category_id,3);
                            if(zs_datadetail!=null){
                                //循环添加绣字颜色
                                EmbroideredColorTestInfo datainfo = new EmbroideredColorTestInfo();
                                datainfo.setCode(zs_datadetail.getCode());
                                datainfo.setColorName(zs_datadetail.getColorName());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setColorImg(zs_datadetail.getColorImg());
                                datainfo.setRemark(zs_datadetail.getRemark());
                                datainfo.setNumbers(zs_datadetail.getNumbers());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code6 = formalCategoryInfoMapper.add_xiuzi_color(datainfo);
                            }
                        } else {//没删
                            //根据编号查询正式的绣字部位有没有，如果有就执行修改，没有就执行添加
                            EmbroideredColorTestInfo zsdingzhiDetail = againEnabledMapper.query_zsxiuziColorByCode(xuzilist2.get(i).getCode(), formalcategory_id);
                            if (zsdingzhiDetail != null) {
                                //循环修改绣字颜色
                                EmbroideredColorTestInfo datainfo = new EmbroideredColorTestInfo();
                                datainfo.setColorName(xuzilist2.get(i).getColorName());
                                datainfo.setColorImg(xuzilist2.get(i).getColorImg());
                                datainfo.setRemark(xuzilist2.get(i).getRemark());
                                datainfo.setNumbers(xuzilist2.get(i).getNumbers());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setUpdateBy(create_by);
                                datainfo.setId(zsdingzhiDetail.getId());
                                code6 = againEnabledMapper.change_zsxiuziColorById(datainfo);
                            } else {
                                //循环添加绣字颜色
                                EmbroideredColorTestInfo datainfo = new EmbroideredColorTestInfo();
                                datainfo.setCode(xuzilist2.get(i).getCode());
                                datainfo.setColorName(xuzilist2.get(i).getColorName());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setColorImg(xuzilist2.get(i).getColorImg());
                                datainfo.setRemark(xuzilist2.get(i).getRemark());
                                datainfo.setNumbers(xuzilist2.get(i).getNumbers());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code6 = formalCategoryInfoMapper.add_xiuzi_color(datainfo);
                            }
                        }
                    }
                }

                if (xuzilist3.size() > 0) {
                    //先执行根据正式品类id删除全部
//                    againEnabledMapper.delete_zs_xiuzifontByTopId(formalcategory_id);
                    for (int i = 0; i < xuzilist3.size(); i++) {
//                        if (xuzilist3.get(i).getStatus() == 0) {//非假删除
//                            //循环添加绣字字体
//                            EmbroideredFontTestInfo datainfo = new EmbroideredFontTestInfo();
//                            datainfo.setCode(xuzilist3.get(i).getCode());
//                            datainfo.setEmbroideredName(xuzilist3.get(i).getEmbroideredName());
//                            datainfo.setCategoryId(formalcategory_id);
//                            datainfo.setEmbroideredImage(xuzilist3.get(i).getEmbroideredImage());
//                            datainfo.setRemark(xuzilist3.get(i).getRemark());
//                            datainfo.setNumbers(xuzilist3.get(i).getNumbers());
//                            datainfo.setIsZitiImg(xuzilist3.get(i).getIsZitiImg());
//                            datainfo.setXiuziSize(xuzilist3.get(i).getXiuziSize());
//                            datainfo.setSysOrgCode(sys_org_code);
//                            datainfo.setCreateBy(create_by);
//                            code66 = formalCategoryInfoMapper.add_xiuzi_fontImg(datainfo);
//                        }

                        if(xuzilist3.get(i).getStatus()!=0){//假删除
                            //根据编号删除正式的绣字部位
                            code66 = againEnabledMapper.delete_zsxiuziFontByCodeplate(xuzilist3.get(i).getCode(),formalcategory_id);
                            System.out.println("删除成功=="+code66);
                            //根据品类id和编号查询当前没有删除的数据--仅仅只有一个
                            EmbroideredFontTestInfo zs_datadetail = againEnabledMapper.query_xiuzifonttailByCode(xuzilist3.get(i).getCode(),category_id,1);
                            if(zs_datadetail!=null){
                                //执行添加
                                EmbroideredFontTestInfo datainfo = new EmbroideredFontTestInfo();
                                datainfo.setCode(zs_datadetail.getCode());
                                datainfo.setEmbroideredName(zs_datadetail.getEmbroideredName());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setEmbroideredImage(zs_datadetail.getEmbroideredImage());
                                datainfo.setNumbers(zs_datadetail.getNumbers());
                                datainfo.setRemark(zs_datadetail.getRemark());
                                datainfo.setIsZitiImg(zs_datadetail.getIsZitiImg());
                                datainfo.setXiuziSize(zs_datadetail.getXiuziSize());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                datainfo.setStatus(0);
                                code66 = categoryInfoMapper.add_xiuzi_fontImg(datainfo);
                            }
                        }else {//没删
                            //根据编号查询正式的绣字部位有没有，如果有就执行修改，没有就执行添加
                            EmbroideredFontTestInfo zsdingzhiDetail = againEnabledMapper.query_zsxiuziFontByCode(xuzilist3.get(i).getCode(),formalcategory_id);
                            if(zsdingzhiDetail != null){
                                EmbroideredFontTestInfo datainfo = new EmbroideredFontTestInfo();
                                datainfo.setEmbroideredName(xuzilist3.get(i).getEmbroideredName());
                                datainfo.setEmbroideredImage(xuzilist3.get(i).getEmbroideredImage());
                                datainfo.setRemark(xuzilist3.get(i).getRemark());
                                datainfo.setNumbers(xuzilist3.get(i).getNumbers());
                                datainfo.setIsZitiImg(xuzilist3.get(i).getIsZitiImg());
                                datainfo.setXiuziSize(xuzilist3.get(i).getXiuziSize());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setUpdateBy(create_by);
                                datainfo.setId(zsdingzhiDetail.getId());
                                code66 = againEnabledMapper.change_zsxiuziFontById(datainfo);
                            }else {
                                //循环添加绣字字体
                                EmbroideredFontTestInfo datainfo = new EmbroideredFontTestInfo();
                                datainfo.setCode(xuzilist3.get(i).getCode());
                                datainfo.setEmbroideredName(xuzilist3.get(i).getEmbroideredName());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setEmbroideredImage(xuzilist3.get(i).getEmbroideredImage());
                                datainfo.setRemark(xuzilist3.get(i).getRemark());
                                datainfo.setNumbers(xuzilist3.get(i).getNumbers());
                                datainfo.setIsZitiImg(xuzilist3.get(i).getIsZitiImg());
                                datainfo.setXiuziSize(xuzilist3.get(i).getXiuziSize());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code66 = formalCategoryInfoMapper.add_xiuzi_fontImg(datainfo);
                            }
                        }
                    }
                }

                if (xiuziHeightlist.size() > 0) {
                    //先执行根据正式品类id删除全部
                    againEnabledMapper.delete_zs_xiuziHeightByTopId(formalcategory_id);
                    for (int i = 0; i < xiuziHeightlist.size(); i++) {
                        //循环添加绣字高度
                        if (xiuziHeightlist.get(i).getStatus() == 0) {//非假删除
                            EmbroidedHeightInfo datainfo = new EmbroidedHeightInfo();
                            datainfo.setEmbroideredHeight(xiuziHeightlist.get(i).getEmbroideredHeight());
                            datainfo.setHeightCode(xiuziHeightlist.get(i).getHeightCode());
                            datainfo.setCategoryId(formalcategory_id);
                            datainfo.setRemark(xiuziHeightlist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code67 = testPlateInfoMapper.add_xiuzi_height(datainfo);
                        }
                    }
                }

                if (bodysizelist1.size() > 0) {
                    //先执行根据正式品类id删除全部
//                    againEnabledMapper.delete_zs_bodysizeByTopId(formalcategory_id);
//                    for (int i = 0; i < bodysizelist1.size(); i++) {
//                        //循环添加身体尺寸
//                        BodySizeTestInfo datainfo = new BodySizeTestInfo();
//                        datainfo.setBodySizename(bodysizelist1.get(i).getBodySizename());
//                        datainfo.setUnit(bodysizelist1.get(i).getUnit());
//                        datainfo.setModuleId(bodysizelist1.get(i).getModuleId());
//                        datainfo.setCategoryId(formalcategory_id);
//                        datainfo.setNumbers(bodysizelist1.get(i).getNumbers());
//                        datainfo.setIsJin(bodysizelist1.get(i).getIsJin());
//                        datainfo.setMax(bodysizelist1.get(i).getMax());
//                        datainfo.setMin(bodysizelist1.get(i).getMin());
//                        datainfo.setIsBitian(bodysizelist1.get(i).getIsBitian());
//                        datainfo.setSysOrgCode(sys_org_code);
//                        datainfo.setCreateBy(create_by);
//                        datainfo.setCode(bodysizelist1.get(i).getCode());
//                        code8 = formalCategoryInfoMapper.add_testbodySize(datainfo);
//                    }
                    for (int i = 0; i < bodysizelist1.size(); i++) {
                        if (bodysizelist1.get(i).getStatus() != 0) {//假删除
                            //根据编号删除正式的绣字部位
                            code66 = againEnabledMapper.delete_zsbodysizeByCodeplate(bodysizelist1.get(i).getCode(), formalcategory_id);
                            System.out.println("删除成功==" + code66);
                            BodySizeTestInfo zsdingzhiDetail = againEnabledMapper.query_testbodysizeByCode(bodysizelist1.get(i).getCode(), category_id);
                            if(zsdingzhiDetail!=null){
                                //循环添加身体尺寸
                                BodySizeTestInfo datainfo = new BodySizeTestInfo();
                                datainfo.setBodySizename(zsdingzhiDetail.getBodySizename());
                                datainfo.setUnit(zsdingzhiDetail.getUnit());
                                datainfo.setModuleId(zsdingzhiDetail.getModuleId());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setNumbers(zsdingzhiDetail.getNumbers());
                                datainfo.setIsJin(zsdingzhiDetail.getIsJin());
                                datainfo.setMax(zsdingzhiDetail.getMax());
                                datainfo.setMin(zsdingzhiDetail.getMin());
                                datainfo.setIsBitian(zsdingzhiDetail.getIsBitian());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                datainfo.setCode(zsdingzhiDetail.getCode());
                                code8 = formalCategoryInfoMapper.add_testbodySize(datainfo);
                            }
                        } else {//没删
                            //根据编号查询正式的绣字部位有没有，如果有就执行修改，没有就执行添加
                            BodySizeTestInfo zsdingzhiDetail = againEnabledMapper.query_zsbodysizeByCode(bodysizelist1.get(i).getCode(), formalcategory_id);
                            if (zsdingzhiDetail != null) {
                                //循环修改身体尺寸
                                BodySizeTestInfo datainfo = new BodySizeTestInfo();
                                datainfo.setBodySizename(bodysizelist1.get(i).getBodySizename());
                                datainfo.setUnit(bodysizelist1.get(i).getUnit());
                                datainfo.setModuleId(bodysizelist1.get(i).getModuleId());
                                datainfo.setNumbers(bodysizelist1.get(i).getNumbers());
                                datainfo.setIsJin(bodysizelist1.get(i).getIsJin());
                                datainfo.setMax(bodysizelist1.get(i).getMax());
                                datainfo.setMin(bodysizelist1.get(i).getMin());
                                datainfo.setIsBitian(bodysizelist1.get(i).getIsBitian());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setUpdateBy(create_by);
                                datainfo.setId(zsdingzhiDetail.getId());
                                code8 = againEnabledMapper.change_zsbodysizeById(datainfo);
                            } else {
                                //循环添加身体尺寸
                                BodySizeTestInfo datainfo = new BodySizeTestInfo();
                                datainfo.setBodySizename(bodysizelist1.get(i).getBodySizename());
                                datainfo.setUnit(bodysizelist1.get(i).getUnit());
                                datainfo.setModuleId(bodysizelist1.get(i).getModuleId());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setNumbers(bodysizelist1.get(i).getNumbers());
                                datainfo.setIsJin(bodysizelist1.get(i).getIsJin());
                                datainfo.setMax(bodysizelist1.get(i).getMax());
                                datainfo.setMin(bodysizelist1.get(i).getMin());
                                datainfo.setIsBitian(bodysizelist1.get(i).getIsBitian());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                datainfo.setCode(bodysizelist1.get(i).getCode());
                                code8 = formalCategoryInfoMapper.add_testbodySize(datainfo);
                            }
                        }
                    }
                }
                if (fanxiulist.size() > 0) {
                    //先执行根据正式品类id删除全部
//                    againEnabledMapper.delete_zs_fanxiusizeByTopId(formalcategory_id);
                    for (int i = 0; i < fanxiulist.size(); i++) {
                        if (fanxiulist.get(i).getStatus() != 0) {//假删除
                            //根据编号删除正式的绣字部位
                            code9 = againEnabledMapper.delete_zsFanxiuByCodeplate(fanxiulist.get(i).getCode(), formalcategory_id);
                            System.out.println("删除成功==" + code66);
                            //根据编号查询正式的绣字部位有没有，如果有就执行修改，没有就执行添加
                            CategoryFanxiuTestInfo zsdingzhiDetail = againEnabledMapper.query_testFanxiuByCode(fanxiulist.get(i).getCode(), category_id);
                            if (zsdingzhiDetail != null) {
                                //循环添加返修
                                CategoryFanxiuTestInfo datainfo = new CategoryFanxiuTestInfo();
                                datainfo.setBodySizename(zsdingzhiDetail.getBodySizename());
                                datainfo.setUnit(zsdingzhiDetail.getUnit());
                                datainfo.setCode(zsdingzhiDetail.getCode());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setNumbers(zsdingzhiDetail.getNumbers());
                                datainfo.setMax(zsdingzhiDetail.getMax());
                                datainfo.setMin(zsdingzhiDetail.getMin());
                                datainfo.setRemark(zsdingzhiDetail.getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code9 = formalCategoryInfoMapper.add_testFanxiuSize(datainfo);
                            }
                        } else {//没删
                            //根据编号查询正式的绣字部位有没有，如果有就执行修改，没有就执行添加
                            CategoryFanxiuTestInfo zsdingzhiDetail = againEnabledMapper.query_zsFanxiuByCode(fanxiulist.get(i).getCode(), formalcategory_id);
                            if (zsdingzhiDetail != null) {
                                //循环修改返修
                                CategoryFanxiuTestInfo datainfo = new CategoryFanxiuTestInfo();
                                datainfo.setBodySizename(fanxiulist.get(i).getBodySizename());
                                datainfo.setUnit(fanxiulist.get(i).getUnit());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setNumbers(fanxiulist.get(i).getNumbers());
                                datainfo.setMax(fanxiulist.get(i).getMax());
                                datainfo.setMin(fanxiulist.get(i).getMin());
                                datainfo.setRemark(fanxiulist.get(i).getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setUpdateBy(create_by);
                                datainfo.setId(zsdingzhiDetail.getId());
                                code9 = againEnabledMapper.change_zsFanxiuById(datainfo);
                            } else {
                                //循环添加返修
                                CategoryFanxiuTestInfo datainfo = new CategoryFanxiuTestInfo();
                                datainfo.setBodySizename(fanxiulist.get(i).getBodySizename());
                                datainfo.setUnit(fanxiulist.get(i).getUnit());
                                datainfo.setCode(fanxiulist.get(i).getCode());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setNumbers(fanxiulist.get(i).getNumbers());
                                datainfo.setMax(fanxiulist.get(i).getMax());
                                datainfo.setMin(fanxiulist.get(i).getMin());
                                datainfo.setRemark(fanxiulist.get(i).getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code9 = formalCategoryInfoMapper.add_testFanxiuSize(datainfo);
                            }
                        }
                    }
                }
                /**
                 * 工艺模块
                 * */
                if (gongyilist.size() > 0) {
                    for (int i = 0; i < gongyilist.size(); i++) {
                        if (gongyilist.get(i).getStatus() == 1) {//假删除
                            //根据编号删除正式的定制项
                            code10 = againEnabledMapper.delete_zsgongyiByCode(gongyilist.get(i).getCategoryCode(), formalcategory_id);
                            System.out.println("删除成功==" + code10);
                            //根据品类id和编号查询当前没有删除的数据--仅仅只有一个
                            MlccCategoryTestInfo zs_datadetail = againEnabledMapper.query_gongyitailByCode(gongyilist.get(i).getCategoryCode(),category_id,3);
                            if(zs_datadetail!=null){
                                //执行添加
                                MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                                datainfo.setCategoryCode(zs_datadetail.getCategoryCode());
                                datainfo.setCategoryName(zs_datadetail.getCategoryName());
                                datainfo.setParentId(zs_datadetail.getParentId());
                                datainfo.setImg(zs_datadetail.getImg());
                                datainfo.setRemark(zs_datadetail.getRemark());
                                datainfo.setTopid(formalcategory_id);
                                datainfo.setIsType(4);
                                datainfo.setCategorySex(zs_datadetail.getCategorySex());
                                datainfo.setNumbers(zs_datadetail.getNumbers());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code10 = formalCategoryInfoMapper.add_category_pinglei2(datainfo);
                            }
                        } else {//没删
                            //根据编号查询正式的定制项有没有，如果有就执行修改，没有就执行添加
                            MlccCategoryInfo zsdingzhiDetail = againEnabledMapper.query_zsgongyiDetailByCode(gongyilist.get(i).getCategoryCode(), formalcategory_id);
                            if (zsdingzhiDetail != null) {
                                //执行修改
                                MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                                datainfo.setCategoryName(gongyilist.get(i).getCategoryName());
                                datainfo.setImg(gongyilist.get(i).getImg());
                                datainfo.setRemark(gongyilist.get(i).getRemark());
                                datainfo.setTopid(formalcategory_id);
                                datainfo.setCategorySex(gongyilist.get(i).getCategorySex());
                                datainfo.setNumbers(gongyilist.get(i).getNumbers());
                                datainfo.setStatus(0);
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setUpdateBy(create_by);
                                datainfo.setId(zsdingzhiDetail.getId());
                                code10 = againEnabledMapper.change_gongyiById(datainfo);
                            } else {
                                //执行添加
                                MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                                datainfo.setCategoryCode(gongyilist.get(i).getCategoryCode());
                                datainfo.setCategoryName(gongyilist.get(i).getCategoryName());
                                datainfo.setParentId(gongyilist.get(i).getParentId());
                                datainfo.setImg(gongyilist.get(i).getImg());
                                datainfo.setRemark(gongyilist.get(i).getRemark());
                                datainfo.setTopid(formalcategory_id);
                                datainfo.setIsType(4);
                                datainfo.setCategorySex(gongyilist.get(i).getCategorySex());
                                datainfo.setNumbers(gongyilist.get(i).getNumbers());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code10 = formalCategoryInfoMapper.add_category_pinglei2(datainfo);
                                if (code10 > 0) {
                                    MlccCategoryInfo gongyidetail2 = formalCategoryInfoMapper.select_canshuDetailById(gongyilist.get(i).getCategoryCode(), formalcategory_id);//根据品类编号查询品类
                                    if (gongyidetail2 != null) {
                                        System.out.println("进来判断这个添加工艺了吗22222===" + "===cde===" + code10 + "===" + gongyidetail2.getId().toString());
                                        for (int j = 0; j < 3; j++) {
                                            AddSystemPriceInfo addSystemPriceInfo = formalCategoryInfoMapper.select_addSystempriceInfo(gongyidetail2.getId().toString(), j + "");
                                            if (addSystemPriceInfo == null) {
                                                System.out.println("进来判断这个添加工艺了吗33333333===" + gongyidetail2.getId().toString());
                                                formalCategoryInfoMapper.add_pricesystem_category(gongyidetail2.getId().toString(), j + "", "工艺类型售价加工", "1",
                                                        create_by, sys_org_code);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                /**
                 * 撞色
                 */
                if (zhuangselist.size() > 0) {
                    for (int i = 0; i < zhuangselist.size(); i++) {
                        if (zhuangselist.get(i).getStatus() == 1) {
                            //根据编号和上级id执行删除
                            code7 = againEnabledMapper.delete_zszhuangseByCode(zhuangselist.get(i).getCode(), formalcategory_id);
                            System.out.println("删除撞色成功==" + code10);
                            ContrastcolorInfo zs_zhuangse = formalCategoryInfoMapper.queryZhuangseDetailByCode(zhuangselist.get(i).getCode(), category_id, 0, 1);
                            if(zs_zhuangse!=null){
                                String praent_id = "", firstId = "";
                                SmalltemplateTestInfo ceshidingdatainfo = categoryInfoMapper.query_dingzhiBydingzhId(zs_zhuangse.getDingzhiId());
                                if (ceshidingdatainfo != null) {
                                    //查询新增的定制项
                                    List<SmalltemplateTestInfo> zsdingzhi_datalist = formalCategoryInfoMapper.query_dingzhiBycategoryId(formalcategory_id);
                                    if (zsdingzhi_datalist.size() > 0) {
                                        for (int k = 0; k < zsdingzhi_datalist.size(); k++) {
                                            if (ceshidingdatainfo.getCode().equals(zsdingzhi_datalist.get(k).getCode())) {
                                                praent_id = zsdingzhi_datalist.get(k).getId().toString();
                                            }
                                        }
                                    }
                                }
                                //根据类别id查询类别详情
                                MlccCategoryTestInfo leibiedatainfo1 = categoryInfoMapper.select_testcategoryDetail(zs_zhuangse.getCategoryId());
                                if (leibiedatainfo1 != null) {
                                    MlccCategoryInfo zsleibie = formalCategoryInfoMapper.select_zscategoryDetailByother(leibiedatainfo1.getCategoryCode(), formalcategory_id, praent_id);
                                    if (zsleibie != null) {
                                        firstId = zsleibie.getId().toString();
                                    }
                                }
                                //循环添加撞色
                                ContrastcolorTestInfo datainfo = new ContrastcolorTestInfo();
                                datainfo.setTopId(formalcategory_id);
                                datainfo.setCode(zs_zhuangse.getCode());
                                datainfo.setContrastColorName(zs_zhuangse.getContrastColorName());
                                datainfo.setCategoryId(firstId);
                                datainfo.setContrastColorImg(zs_zhuangse.getContrastColorImg());
                                datainfo.setDingzhiId(praent_id);
                                datainfo.setRemark(zs_zhuangse.getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code7 = formalCategoryInfoMapper.add_zhuangse(datainfo);
                            }
                        } else {
                            ContrastcolorInfo zs_zhuangse = formalCategoryInfoMapper.queryZhuangseDetailByCode(zhuangselist.get(i).getCode(), formalcategory_id, 0, 0);
                            String praent_id = "", firstId = "";
                            SmalltemplateTestInfo ceshidingdatainfo = categoryInfoMapper.query_dingzhiBydingzhId(zhuangselist.get(i).getDingzhiId());
                            if (ceshidingdatainfo != null) {
                                //查询新增的定制项
                                List<SmalltemplateTestInfo> zsdingzhi_datalist = formalCategoryInfoMapper.query_dingzhiBycategoryId(formalcategory_id);
                                if (zsdingzhi_datalist.size() > 0) {
                                    for (int k = 0; k < zsdingzhi_datalist.size(); k++) {
                                        if (ceshidingdatainfo.getCode().equals(zsdingzhi_datalist.get(k).getCode())) {
                                            praent_id = zsdingzhi_datalist.get(k).getId().toString();
                                        }
                                    }
                                }
                            }
                            //根据类别id查询类别详情
                            MlccCategoryTestInfo leibiedatainfo1 = categoryInfoMapper.select_testcategoryDetail(zhuangselist.get(i).getCategoryId());
                            if (leibiedatainfo1 != null) {
                                MlccCategoryInfo zsleibie = formalCategoryInfoMapper.select_zscategoryDetailByother(leibiedatainfo1.getCategoryCode(), formalcategory_id, praent_id);
                                if (zsleibie != null) {
                                    firstId = zsleibie.getId().toString();
                                }
                            }
                            if (zs_zhuangse != null) {
                                //循环修改撞色
                                System.out.println("走修改3===" + praent_id + "===" + firstId);
                                ContrastcolorTestInfo datainfo = new ContrastcolorTestInfo();
                                datainfo.setCode(zhuangselist.get(i).getCode());
                                datainfo.setContrastColorName(zhuangselist.get(i).getContrastColorName());
                                datainfo.setCategoryId(firstId);
                                datainfo.setContrastColorImg(zhuangselist.get(i).getContrastColorImg());
                                datainfo.setDingzhiId(praent_id);
                                datainfo.setRemark(zhuangselist.get(i).getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setUpdateBy(create_by);
                                datainfo.setId(zs_zhuangse.getId());
                                code7 = formalCategoryInfoMapper.change_zhuangse(datainfo);
                            } else {
                                //循环添加撞色
                                System.out.println("走增加3===" + praent_id + "===" + firstId);
                                ContrastcolorTestInfo datainfo = new ContrastcolorTestInfo();
                                datainfo.setTopId(formalcategory_id);
                                datainfo.setCode(zhuangselist.get(i).getCode());
                                datainfo.setContrastColorName(zhuangselist.get(i).getContrastColorName());
                                datainfo.setCategoryId(firstId);
                                datainfo.setContrastColorImg(zhuangselist.get(i).getContrastColorImg());
                                datainfo.setDingzhiId(praent_id);
                                datainfo.setRemark(zhuangselist.get(i).getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code7 = formalCategoryInfoMapper.add_zhuangse(datainfo);
                            }
                        }
                    }
                }
                /**
                 * 加急项的上级
                 */
                if (syspricelist.size() > 0) {
                    for (int i = 0; i < syspricelist.size(); i++) {
                        if (syspricelist.get(i).getStatus() != 0) {//假删除
                            //根据编号和上级删除正式的上级加急项
                            code11 = againEnabledMapper.delete_zs_addsystempriceByCode(syspricelist.get(i).getPremiumCode(), formalcategory_id);
                            System.out.println("删除成功==" + code11);
                        } else {//没删
                            //根据编号查询正式的定制项有没有，如果有就执行修改，没有就执行添加
                            AddSystemPriceInfo zs_topshoufei = againEnabledMapper.query_zs_addsystempriceBycode(syspricelist.get(i).getPremiumCode(), formalcategory_id, 1);
                            if (zs_topshoufei != null) {
                                //执行修改
                                AddSystemPriceInfo datainfo = new AddSystemPriceInfo();
                                datainfo.setPremiumItem(syspricelist.get(i).getPremiumItem());
                                datainfo.setPremiumCode(syspricelist.get(i).getPremiumCode());
                                datainfo.setRemark(syspricelist.get(i).getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setUpdateBy(create_by);
                                datainfo.setPartentId("0");
                                datainfo.setIsTop(1);
                                datainfo.setNumbers(syspricelist.get(i).getNumbers());
                                datainfo.setId(zs_topshoufei.getId());
                                code11 = formalCategoryInfoMapper.change_shoufei(datainfo);
                            } else {
                                //执行添加
                                AddSystemPriceInfo datainfo = new AddSystemPriceInfo();
                                datainfo.setPremiumItem(syspricelist.get(i).getPremiumItem());
                                datainfo.setPremiumCode(syspricelist.get(i).getPremiumCode());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setType(syspricelist.get(i).getType());
                                datainfo.setRemark(syspricelist.get(i).getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                datainfo.setPartentId("0");
                                datainfo.setIsTop(1);
                                datainfo.setNumbers(syspricelist.get(i).getNumbers());
                                code11 = formalCategoryInfoMapper.add_fomal_syspriceinfo(datainfo);
                            }
                        }
                    }
                }
                /**
                 * 加价类型下的加价项
                 */
                if (syspricelist2.size() > 0) {
                    for (int i = 0; i < syspricelist2.size(); i++) {
                        //根据编码查询系统加急项
                        String praent_id = "";
                        AddSystemPriceInfo ceshidingdatainfo = categoryInfoMapper.query_addsyspriceDetail(syspricelist2.get(i).getPartentId());
                        if (ceshidingdatainfo != null) {
                            //查询新增的上级加急项
                            List<AddSystemPriceInfo> zsdingzhi_datalist = testPlateInfoMapper.query_AllsyspriceBypingleiId(formalcategory_id, 1);
                            if (zsdingzhi_datalist.size() > 0) {
                                for (int k = 0; k < zsdingzhi_datalist.size(); k++) {
                                    if (ceshidingdatainfo.getPremiumCode().equals(zsdingzhi_datalist.get(k).getPremiumCode())) {
                                        praent_id = zsdingzhi_datalist.get(k).getId().toString();
                                        break;
                                    }
                                }
                            }
                        }
                        if (syspricelist2.get(i).getStatus() != 0) {//假删除
                            //根据编号和上级id删除正式的定制项下的参数
                            code12 = againEnabledMapper.delete_zs_addsystempriceByCode(syspricelist2.get(i).getPremiumCode(), formalcategory_id);
                            System.out.println("删除成功==" + code12);
                        } else {//没删
                            //根据编号查询正式的定制项有没有，如果有就执行修改，没有就执行添加
                            AddSystemPriceInfo zs_shoufei = againEnabledMapper.query_zs_addsystempriceBycode(syspricelist2.get(i).getPremiumCode(), formalcategory_id, 0);
                            if (zs_shoufei != null) {
                                //执行修改
                                AddSystemPriceInfo datainfo = new AddSystemPriceInfo();
                                datainfo.setPremiumItem(syspricelist2.get(i).getPremiumItem());
                                datainfo.setPremiumCode(syspricelist2.get(i).getPremiumCode());
                                datainfo.setRemark(syspricelist2.get(i).getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setUpdateBy(create_by);
                                datainfo.setIsTop(0);
                                datainfo.setNumbers(syspricelist2.get(i).getNumbers());
                                datainfo.setId(zs_shoufei.getId());
                                code11 = formalCategoryInfoMapper.change_shoufei(datainfo);
                            } else {
                                //执行添加
                                AddSystemPriceInfo datainfo = new AddSystemPriceInfo();
                                datainfo.setPremiumItem(syspricelist2.get(i).getPremiumItem());
                                datainfo.setPremiumCode(syspricelist2.get(i).getPremiumCode());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setType(syspricelist2.get(i).getType());
                                datainfo.setRemark(syspricelist2.get(i).getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                datainfo.setPartentId(praent_id);//上级
                                datainfo.setIsTop(0);
                                datainfo.setNumbers(syspricelist2.get(i).getNumbers());
                                code11 = formalCategoryInfoMapper.add_fomal_syspriceinfo(datainfo);
                            }
                        }
                    }
                }
                Long startTs2 = System.currentTimeMillis(); // 当前时间戳
                System.out.println("输出时间========" + (startTs2 - startTs1));
                System.out.println("各个code==" + code2 + "=" + code3 + "=" + code4 + "=" + code5 + "=" + code6 + "=" + code66 + "=" + code7 + "=" + code8 + "=" + code9 + "=" + code10 + "==67==" + code67);
                if (code2 > 0 || code3 > 0 || code4 > 0 || code5 > 0 || code6 > 0 || code66 > 0 || code67 > 0 || code7 > 0 || code8 > 0 || code9 > 0 || code10 > 0 || code11 > 0) {
                    //测试区
                    formalCategoryInfoMapper.add_qiyong_record(category_id, "0", "0", zhengshi_categoryName + " 【再次】 启用成为正式品类", create_by, sys_org_code);
                    //正式插入记录
                    formalCategoryInfoMapper.add_qiyong_record(formalcategory_id, "0", "0", "已由草稿件" + zhengshi_categoryName + " 【再次】 启用成为正式品类", create_by, sys_org_code);
                    formalCategoryInfoMapper.update_category_size(formalcategory_id, issize);//修改是否采用体型数据
                    return 10;
                } else {
                    return 1;
                }
            }
        } else {//第一次启用
            //赋值测试类别id
            testcategoryDetail.setTestcategoryId(testcategoryDetail.getId().toString());
            testcategoryDetail.setIsSize(testcategoryDetail.getIsSize());
            int code1 = formalCategoryInfoMapper.add_category_pinglei2(testcategoryDetail);
            int code2 = 0, code3 = 0, code4 = 0, code5 = 0, code6 = 0, code7 = 0, code8 = 0, code9 = 0, code10 = 0, code66 = 0, code11 = 0, code67 = 0;
            if (code1 > 0) {
                //根据品类id查询定制项
                List<SmalltemplateTestInfo> dingzhilist = categoryInfoMapper.query_dingzhiBycategoryId(category_id);
                //根据品类id查询定制项下的参数
                List<MlccCategoryTestInfo> canshulist = formalCategoryInfoMapper.query_AllcanshuBypingleiId(category_id);
                //根据品类id查询互斥项
                List<MutexTestInfo> huchilist = formalCategoryInfoMapper.query_AllhuchiBypingleiId(category_id);
                //根据品类id查询绣字部位
                List<CategoryLocationTestInfo> xuzilist1 = formalCategoryInfoMapper.query_Allxiuzi1BypingleiId(category_id);
                //根据品类id查询绣字颜色
                List<EmbroideredColorTestInfo> xuzilist2 = formalCategoryInfoMapper.query_AllxiuziColorBypingleiId(category_id);
                //根据品类id查询绣字图片
                List<EmbroideredFontTestInfo> xuzilist3 = formalCategoryInfoMapper.query_AllxiuziFontBypingleiId(category_id);
                //根据品类id查询撞色
                List<ContrastcolorTestInfo> zhuangselist = formalCategoryInfoMapper.query_AllzhuangseBypingleiId(category_id);
                //根据品类id查询净体尺寸
                List<BodySizeTestInfo> bodysizelist1 = formalCategoryInfoMapper.query_AlljingtiBodysizeBypingleiId(category_id);
                //根据品类id查询返修
                List<CategoryFanxiuTestInfo> fanxiulist = formalCategoryInfoMapper.query_AllFanxiuBypingleiId(category_id);
                //根据品类id查询工艺类型
                List<MlccCategoryTestInfo> gongyilist = formalCategoryInfoMapper.query_AllGongyiBypingleiId(category_id);
                //根据品类id查询系统加急---cesih
                List<AddSystemPriceInfo> syspricelist = formalCategoryInfoMapper.query_AllsyspriceBypingleiId(category_id, 1);
                List<AddSystemPriceInfo> syspricelist2 = formalCategoryInfoMapper.query_AllsyspriceBypingleiId(category_id, 0);
                //根据品类id查询所有绣字高度-测试
                List<EmbroidedHeightInfo> xiuziHeightlist = formalCategoryInfoMapper.query_AllxiuziHeightBypingleiId(category_id);

                MlccCategoryInfo pingleiDetail = againEnabledMapper.select_zscategoryDetail(testcategoryDetail.getCategoryCode());
                if (pingleiDetail != null) {
                    String zspingleiId = pingleiDetail.getId().toString();//正式品类id
                    zhengshi_categoryId = pingleiDetail.getId().toString();//正式品类id
                    zhengshi_categoryName = pingleiDetail.getCategoryName();
                    if (dingzhilist.size() > 0) {
                        for (int i = 0; i < dingzhilist.size(); i++) {
                            //循环添加定制项
                            SmalltemplateTestInfo datainfo = new SmalltemplateTestInfo();
                            datainfo.setModuleId(dingzhilist.get(i).getModuleId());
                            datainfo.setCategoryId(zspingleiId);
                            datainfo.setCode(dingzhilist.get(i).getCode());
                            datainfo.setParameter(dingzhilist.get(i).getParameter());
                            datainfo.setImgs(dingzhilist.get(i).getImgs());
                            datainfo.setNumbers(dingzhilist.get(i).getNumbers());
                            datainfo.setIstype(dingzhilist.get(i).getIstype());
                            datainfo.setRemark(dingzhilist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code2 = formalCategoryInfoMapper.add_dingzhi(datainfo);
                        }
                    }
                    if (canshulist.size() > 0) {
                        for (int i = 0; i < canshulist.size(); i++) {
                            String praent_id = "";
                            SmalltemplateTestInfo ceshidingdatainfo = categoryInfoMapper.query_dingzhiBydingzhId(canshulist.get(i).getParentId());
                            if (ceshidingdatainfo != null) {
                                //查询新增的定制项
                                List<SmalltemplateTestInfo> zsdingzhi_datalist = formalCategoryInfoMapper.query_dingzhiBycategoryId(zspingleiId);
                                if (zsdingzhi_datalist.size() > 0) {
                                    for (int k = 0; k < zsdingzhi_datalist.size(); k++) {
                                        if (ceshidingdatainfo.getCode().equals(zsdingzhi_datalist.get(k).getCode())) {
                                            praent_id = zsdingzhi_datalist.get(k).getId().toString();
                                        }
                                    }
                                }
                            }
                            //循环添加定制项下的参数
                            MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                            datainfo.setCategoryName(canshulist.get(i).getCategoryName());
                            datainfo.setCategoryCode(canshulist.get(i).getCategoryCode());
                            datainfo.setParentId(praent_id);//正式的上级id
                            datainfo.setImg(canshulist.get(i).getImg());
                            datainfo.setTopid(zspingleiId);
                            datainfo.setNumbers(canshulist.get(i).getNumbers());
                            datainfo.setIsType(canshulist.get(i).getIsType());
                            datainfo.setCost(canshulist.get(i).getCost());
                            datainfo.setTeamPrice2(canshulist.get(i).getTeamPrice2());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            datainfo.setStatus(0);
                            code3 = formalCategoryInfoMapper.add_dingzhi_canshu(datainfo);
                        }
                    }
                    if (huchilist.size() > 0) {
                        for (int i = 0; i < huchilist.size(); i++) {
                            //查询新增的定制项
                            String dingzhi1 = "", dingzhi2 = "";
                            String firstId = "", secoundId = "";
                            List<SmalltemplateTestInfo> zsdingzhi_datalist = formalCategoryInfoMapper.query_dingzhiBycategoryId(zspingleiId);
                            SmalltemplateTestInfo ceshidingdatainfo1 = categoryInfoMapper.query_dingzhiBydingzhId(huchilist.get(i).getDingzhi1());
                            SmalltemplateTestInfo ceshidingdatainfo2 = categoryInfoMapper.query_dingzhiBydingzhId(huchilist.get(i).getDingzhi2());
                            if (ceshidingdatainfo1 != null) {
                                if (zsdingzhi_datalist.size() > 0) {
                                    for (int k = 0; k < zsdingzhi_datalist.size(); k++) {
                                        if (ceshidingdatainfo1.getCode().equals(zsdingzhi_datalist.get(k).getCode())) {
                                            dingzhi1 = zsdingzhi_datalist.get(k).getId().toString();
                                            break;
                                        }
                                    }
                                }
                            }
                            if (ceshidingdatainfo2 != null) {
                                if (zsdingzhi_datalist.size() > 0) {
                                    for (int k = 0; k < zsdingzhi_datalist.size(); k++) {
                                        if (ceshidingdatainfo2.getCode().equals(zsdingzhi_datalist.get(k).getCode())) {
                                            dingzhi2 = zsdingzhi_datalist.get(k).getId().toString();
                                            break;
                                        }
                                    }
                                }
                            }
                            //根据类别id查询类别详情
                            MlccCategoryTestInfo leibiedatainfo1 = categoryInfoMapper.select_testcategoryDetail(huchilist.get(i).getCategoryId());
                            if (leibiedatainfo1 != null) {
                                MlccCategoryInfo zsleibie = formalCategoryInfoMapper.select_zscategoryDetailByother(leibiedatainfo1.getCategoryCode(), zspingleiId, dingzhi1);
                                if (zsleibie != null) {
                                    firstId = zsleibie.getId().toString();
                                }
                            }
                            String canshuids[] = huchilist.get(i).getCategoryOther().split(",");
                            String strbody = "";
                            for (String s : canshuids) {
                                //根据类别id查询类别详情
                                MlccCategoryTestInfo leibiedatainfo2 = categoryInfoMapper.select_testcategoryDetail(s);
                                if (leibiedatainfo2 != null) {
                                    MlccCategoryInfo zsleibie = formalCategoryInfoMapper.select_zscategoryDetailByother(leibiedatainfo2.getCategoryCode(), zspingleiId, dingzhi2);
                                    if (zsleibie != null) {
                                        strbody += zsleibie.getId().toString() + ",";
                                    }
                                }
                            }
                            secoundId = strbody.substring(0, strbody.length() - 1);
                            //循环添加互斥
                            MutexTestInfo datainfo = new MutexTestInfo();
                            datainfo.setMutexName(huchilist.get(i).getMutexName());
                            datainfo.setTopId(zspingleiId);
                            datainfo.setCategoryId(firstId);
                            datainfo.setCategoryOther(secoundId);
                            datainfo.setMutexReason(huchilist.get(i).getMutexReason());
                            datainfo.setStatus(huchilist.get(i).getStatus());
                            datainfo.setCode(huchilist.get(i).getCode());
                            datainfo.setDingzhi1(dingzhi1);
                            datainfo.setDingzhi2(dingzhi2);
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code4 = formalCategoryInfoMapper.add_huchi(datainfo);
                        }
                    }
                    if (xuzilist1.size() > 0) {
                        for (int i = 0; i < xuzilist1.size(); i++) {
                            //循环添加绣字部位
                            CategoryLocationTestInfo datainfo = new CategoryLocationTestInfo();
                            datainfo.setCode(xuzilist1.get(i).getCode());
                            datainfo.setXiuziLocaltion(xuzilist1.get(i).getXiuziLocaltion());
                            datainfo.setCategoryId(zspingleiId);
                            datainfo.setRemark(xuzilist1.get(i).getRemark());
                            datainfo.setNumbers(xuzilist1.get(i).getNumbers());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code5 = formalCategoryInfoMapper.add_xiuzi_location(datainfo);
                        }
                    }
                    if (xuzilist2.size() > 0) {
                        for (int i = 0; i < xuzilist2.size(); i++) {
                            //循环添加绣字颜色
                            EmbroideredColorTestInfo datainfo = new EmbroideredColorTestInfo();
                            datainfo.setCode(xuzilist2.get(i).getCode());
                            datainfo.setColorName(xuzilist2.get(i).getColorName());
                            datainfo.setCategoryId(zspingleiId);
                            datainfo.setColorImg(xuzilist2.get(i).getColorImg());
                            datainfo.setRemark(xuzilist2.get(i).getRemark());
                            datainfo.setNumbers(xuzilist2.get(i).getNumbers());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code6 = formalCategoryInfoMapper.add_xiuzi_color(datainfo);
                        }
                    }
                    if (xuzilist3.size() > 0) {
                        for (int i = 0; i < xuzilist3.size(); i++) {
                            //循环添加绣字字体
                            EmbroideredFontTestInfo datainfo = new EmbroideredFontTestInfo();
                            datainfo.setCode(xuzilist3.get(i).getCode());
                            datainfo.setEmbroideredName(xuzilist3.get(i).getEmbroideredName());
                            datainfo.setCategoryId(zspingleiId);
                            datainfo.setEmbroideredImage(xuzilist3.get(i).getEmbroideredImage());
                            datainfo.setRemark(xuzilist3.get(i).getRemark());
                            datainfo.setNumbers(xuzilist3.get(i).getNumbers());
                            datainfo.setIsZitiImg(xuzilist3.get(i).getIsZitiImg());
                            datainfo.setXiuziSize(xuzilist3.get(i).getXiuziSize());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code66 = formalCategoryInfoMapper.add_xiuzi_fontImg(datainfo);
                        }
                    }
                    if (xiuziHeightlist.size() > 0) {
                        for (int i = 0; i < xiuziHeightlist.size(); i++) {
                            //循环添加绣字高度
                            EmbroidedHeightInfo datainfo = new EmbroidedHeightInfo();
                            datainfo.setEmbroideredHeight(xiuziHeightlist.get(i).getEmbroideredHeight());
                            datainfo.setHeightCode(xiuziHeightlist.get(i).getHeightCode());
                            datainfo.setCategoryId(zspingleiId);
                            datainfo.setRemark(xiuziHeightlist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code67 = testPlateInfoMapper.add_xiuzi_height(datainfo);
                        }
                    }
                    if (zhuangselist.size() > 0) {
                        for (int i = 0; i < zhuangselist.size(); i++) {
                            String praent_id = "", firstId = "";
                            SmalltemplateTestInfo ceshidingdatainfo = categoryInfoMapper.query_dingzhiBydingzhId(zhuangselist.get(i).getDingzhiId());
                            if (ceshidingdatainfo != null) {
                                //查询新增的定制项
                                List<SmalltemplateTestInfo> zsdingzhi_datalist = formalCategoryInfoMapper.query_dingzhiBycategoryId(zspingleiId);
                                if (zsdingzhi_datalist.size() > 0) {
                                    for (int k = 0; k < zsdingzhi_datalist.size(); k++) {
                                        if (ceshidingdatainfo.getCode().equals(zsdingzhi_datalist.get(k).getCode())) {
                                            praent_id = zsdingzhi_datalist.get(k).getId().toString();
                                        }
                                    }
                                }
                            }
                            //根据类别id查询类别详情
                            MlccCategoryTestInfo leibiedatainfo1 = categoryInfoMapper.select_testcategoryDetail(zhuangselist.get(i).getCategoryId());
                            if (leibiedatainfo1 != null) {
                                MlccCategoryInfo zsleibie = formalCategoryInfoMapper.select_zscategoryDetailByother(leibiedatainfo1.getCategoryCode(), zspingleiId, praent_id);
                                if (zsleibie != null) {
                                    firstId = zsleibie.getId().toString();
                                }
                            }
                            //循环添加撞色
                            ContrastcolorTestInfo datainfo = new ContrastcolorTestInfo();
                            datainfo.setTopId(zspingleiId);
                            datainfo.setCode(zhuangselist.get(i).getCode());
                            datainfo.setContrastColorName(zhuangselist.get(i).getContrastColorName());
                            datainfo.setCategoryId(firstId);
                            datainfo.setContrastColorImg(zhuangselist.get(i).getContrastColorImg());
                            datainfo.setDingzhiId(praent_id);
                            datainfo.setRemark(zhuangselist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code7 = formalCategoryInfoMapper.add_zhuangse(datainfo);
                        }
                    }
                    if (bodysizelist1.size() > 0) {
                        for (int i = 0; i < bodysizelist1.size(); i++) {
                            //循环添加身体尺寸
                            BodySizeTestInfo datainfo = new BodySizeTestInfo();
                            datainfo.setBodySizename(bodysizelist1.get(i).getBodySizename());
                            datainfo.setUnit(bodysizelist1.get(i).getUnit());
                            datainfo.setModuleId(bodysizelist1.get(i).getModuleId());
                            datainfo.setCategoryId(zspingleiId);
                            datainfo.setNumbers(bodysizelist1.get(i).getNumbers());
                            datainfo.setIsJin(bodysizelist1.get(i).getIsJin());
                            datainfo.setMax(bodysizelist1.get(i).getMax());
                            datainfo.setMin(bodysizelist1.get(i).getMin());
                            datainfo.setIsBitian(bodysizelist1.get(i).getIsBitian());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            datainfo.setCode(bodysizelist1.get(i).getCode());
                            code8 = formalCategoryInfoMapper.add_testbodySize(datainfo);
                        }
                    }
                    if (fanxiulist.size() > 0) {
                        for (int i = 0; i < fanxiulist.size(); i++) {
                            //循环添加返修
                            CategoryFanxiuTestInfo datainfo = new CategoryFanxiuTestInfo();
                            datainfo.setBodySizename(fanxiulist.get(i).getBodySizename());
                            datainfo.setUnit(fanxiulist.get(i).getUnit());
                            datainfo.setCategoryId(zspingleiId);
                            datainfo.setNumbers(fanxiulist.get(i).getNumbers());
                            datainfo.setMax(fanxiulist.get(i).getMax());
                            datainfo.setMin(fanxiulist.get(i).getMin());
                            datainfo.setRemark(fanxiulist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            datainfo.setCode(fanxiulist.get(i).getCode());
                            code9 = formalCategoryInfoMapper.add_testFanxiuSize(datainfo);
                        }
                    }
                    if (syspricelist.size() > 0) {
                        for (int i = 0; i < syspricelist.size(); i++) {
                            //循环添加系统加急--上级
                            AddSystemPriceInfo datainfo = new AddSystemPriceInfo();
                            datainfo.setPremiumItem(syspricelist.get(i).getPremiumItem());
                            datainfo.setPremiumCode(syspricelist.get(i).getPremiumCode());
                            datainfo.setCategoryId(zspingleiId);
                            datainfo.setType(syspricelist.get(i).getType());
                            datainfo.setRemark(syspricelist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            datainfo.setPartentId("0");
                            datainfo.setIsTop(1);
                            datainfo.setNumbers(syspricelist.get(i).getNumbers());
                            code11 = formalCategoryInfoMapper.add_fomal_syspriceinfo(datainfo);
                        }
                    }

                    if (syspricelist2.size() > 0) {
                        for (int i = 0; i < syspricelist2.size(); i++) {
                            //根据编码查询系统加急项
                            String praent_id = "";
                            AddSystemPriceInfo ceshidingdatainfo = categoryInfoMapper.query_addsyspriceDetail(syspricelist2.get(i).getPartentId());
                            if (ceshidingdatainfo != null) {
                                //查询新增的上级加急项
                                List<AddSystemPriceInfo> zsdingzhi_datalist = testPlateInfoMapper.query_AllsyspriceBypingleiId(zspingleiId, 1);
                                if (zsdingzhi_datalist.size() > 0) {
                                    for (int k = 0; k < zsdingzhi_datalist.size(); k++) {
                                        if (ceshidingdatainfo.getPremiumCode().equals(zsdingzhi_datalist.get(k).getPremiumCode())) {
                                            praent_id = zsdingzhi_datalist.get(k).getId().toString();
                                            break;
                                        }
                                    }
                                }
                            }
                            //循环添加系统加急--下级
                            AddSystemPriceInfo datainfo = new AddSystemPriceInfo();
                            datainfo.setPremiumItem(syspricelist2.get(i).getPremiumItem());
                            datainfo.setPremiumCode(syspricelist2.get(i).getPremiumCode());
                            datainfo.setCategoryId(zspingleiId);
                            datainfo.setType(syspricelist2.get(i).getType());
                            datainfo.setRemark(syspricelist2.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            datainfo.setPartentId(praent_id);//上级
                            datainfo.setIsTop(0);
                            datainfo.setNumbers(syspricelist2.get(i).getNumbers());
                            code11 = formalCategoryInfoMapper.add_fomal_syspriceinfo(datainfo);
                        }
                    }

                    if (gongyilist.size() > 0) {
                        for (int i = 0; i < gongyilist.size(); i++) {
                            //循环添加工艺
                            MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                            datainfo.setCategoryCode(gongyilist.get(i).getCategoryCode());
                            datainfo.setCategoryName(gongyilist.get(i).getCategoryName());
                            datainfo.setParentId(gongyilist.get(i).getParentId());
                            datainfo.setImg(gongyilist.get(i).getImg());
                            datainfo.setRemark(gongyilist.get(i).getRemark());
                            datainfo.setTopid(zspingleiId);
                            datainfo.setIsType(4);
                            datainfo.setCategorySex(gongyilist.get(i).getCategorySex());
                            datainfo.setNumbers(gongyilist.get(i).getNumbers());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code10 = formalCategoryInfoMapper.add_category_pinglei2(datainfo);
                            if (code10 > 0) {
                                MlccCategoryInfo gongyidetail = formalCategoryInfoMapper.select_zscategoryDetail2(gongyilist.get(i).getCategoryCode(), zspingleiId);//根据品类编号查询品类
                                if (gongyidetail != null) {
                                    for (int j = 0; j < 3; j++) {
                                        formalCategoryInfoMapper.add_pricesystem_category(gongyidetail.getId().toString(), j + "", "工艺类型售价加工", "1",
                                                create_by, sys_org_code);
                                    }
                                }
                            }

                        }
                    }
                }
                System.out.println("各个code==" + code2 + "=" + code3 + "=" + code4 + "=" + code5 + "=" + code6 + "=" + code66 + "=" + code7 + "=" + code8 + "=" + code9 + "=" + code10);
                if (code2 > 0 || code3 > 0 || code4 > 0 || code5 > 0 || code6 > 0 || code66 > 0 || code67 > 0 || code7 > 0 || code8 > 0 || code9 > 0 || code10 > 0 || code11 > 0) {
                    //测试区
                    formalCategoryInfoMapper.add_qiyong_record(category_id, "0", "0", zhengshi_categoryName + "正式启用成为正式品类", create_by, sys_org_code);
                    //正式插入记录
                    formalCategoryInfoMapper.add_qiyong_record(zhengshi_categoryId, "0", "0", "已由草稿件" + zhengshi_categoryName + "正式启用成为正式品类", create_by, sys_org_code);
                    //修改正式品类的状态---一开始启用为未上架
                    formalCategoryInfoMapper.edit_category_status(zhengshi_categoryId, "2");
                    for (int j = 0; j < 3; j++) {
                        formalCategoryInfoMapper.add_pricesystem_category(zhengshi_categoryId, j + "", "品类成本项加工", "0",
                                create_by, sys_org_code);
                    }
                    return 0;
                } else {
                    return 1;
                }
            } else {
                return 500;
            }
        }
    }

    /**
     * 还原品类草稿件
     * @param category_id 测试版号ID
     */
    @Override
    public int rewrite_category_caogao(String category_id) {
        Long start_time = System.currentTimeMillis();
        //获取登录用户信息
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String sys_org_code = sysUser.getOrgCode();
        String create_by = sysUser.getUsername();
        String pingleiName = "", formal_categoryId = "";
        String plate_id = category_id;
        //查询正式的品类详情
        MlccCategoryInfo formalpinglei = formalCategoryInfoMapper.select_formal_categoryDetail(category_id);//根据测试品类id查询正式品类
        if (formalpinglei != null) {
            formal_categoryId = formalpinglei.getId().toString();
            pingleiName = formalpinglei.getCategoryName();
            //根据品类id查询定制项
            List<SmalltemplateTestInfo> dingzhilist = testPlateInfoMapper.query_dingzhiBycategoryId(formal_categoryId);
            //根据品类id查询定制项下的参数
            List<MlccCategoryTestInfo> canshulist = testPlateInfoMapper.query_AllcanshuBypingleiId(formal_categoryId);
            //根据品类id查询互斥项
            List<MutexTestInfo> huchilist = testPlateInfoMapper.query_AllhuchiBypingleiId(formal_categoryId);
            //根据品类id查询绣字部位
            List<CategoryLocationTestInfo> xuzilist1 = testPlateInfoMapper.query_Allxiuzi1BypingleiId(formal_categoryId);
            //根据品类id查询绣字颜色
            List<EmbroideredColorTestInfo> xuzilist2 = testPlateInfoMapper.query_AllxiuziColorBypingleiId(formal_categoryId);
            //根据品类id查询绣字图片
            List<EmbroideredFontTestInfo> xuzilist3 = testPlateInfoMapper.query_AllxiuziFontBypingleiId(formal_categoryId);
            //根据品类id查询撞色
            List<ContrastcolorTestInfo> zhuangselist = testPlateInfoMapper.query_AllzhuangseBypingleiId(formal_categoryId);
            //根据品类id查询净体尺寸
            List<BodySizeTestInfo> bodysizelist1 = testPlateInfoMapper.query_AlljingtiBodysizeBypingleiId(formal_categoryId);
            //根据品类id查询返修
            List<CategoryFanxiuTestInfo> fanxiulist = testPlateInfoMapper.query_AllFanxiuBypingleiId(formal_categoryId);
            //根据品类id查询工艺类型
            List<MlccCategoryTestInfo> gongyilist = testPlateInfoMapper.query_AllGongyiBypingleiId(formal_categoryId);
            //根据品类id查询所有绣字高度
            List<EmbroidedHeightInfo> xiuziHeightlist = testPlateInfoMapper.query_AllHeightBypingleiId(formal_categoryId);
            //根据品类id查询所有的收费项
            List<AddSystemPriceInfo> shoufeilist = testPlateInfoMapper.query_AllsyspriceBypingleiId(formal_categoryId,1);
            //根据品类id查询所有的收费项
            List<AddSystemPriceInfo> shoufeilist2 = testPlateInfoMapper.query_AllsyspriceBypingleiId(formal_categoryId,0);

            int code1 = 0, code2 = 0, code3 = 0, code4 = 0, code5 = 0, code6 = 0, code7 = 0,
                    code8 = 0, code9 = 0, code10 = 0,code11=0,code12=0,code13=0;

            /**
             * 绣字高度模块
             * */
            if (xiuziHeightlist.size() > 0) {
                //在增加前执行删除
                code11 = againEnabledMapper.real_delete_xiuziHeight(plate_id);
                for (int i = 0; i < xiuziHeightlist.size(); i++) {
                    //循环添加绣字高度
                    EmbroidedHeightInfo datainfo = new EmbroidedHeightInfo();
                    datainfo.setEmbroideredHeight(xiuziHeightlist.get(i).getEmbroideredHeight());
                    datainfo.setHeightCode(xiuziHeightlist.get(i).getHeightCode());
                    datainfo.setCategoryId(plate_id);
                    datainfo.setRemark(xiuziHeightlist.get(i).getRemark());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    code11 = categoryInfoMapper.add_xiuzi_height(datainfo);
                }
            }
            /**
             * 收费服务
             * */
            if (shoufeilist.size() > 0) {
                code12 = againEnabledMapper.real_delete_sfprice(plate_id);
                for (int i = 0; i < shoufeilist.size(); i++) {
                    //循环添加收费
                    AddSystemPriceInfo datainfo = new AddSystemPriceInfo();
                    datainfo.setPremiumItem(shoufeilist.get(i).getPremiumItem());
                    datainfo.setPremiumCode(shoufeilist.get(i).getPremiumCode());
                    datainfo.setCategoryId(plate_id);
                    datainfo.setType(shoufeilist.get(i).getType());
                    datainfo.setRemark(shoufeilist.get(i).getRemark());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    datainfo.setPartentId("0");
                    datainfo.setIsTop(1);
                    datainfo.setNumbers(shoufeilist.get(i).getNumbers());
                    code12 = categoryInfoMapper.add_addsysytemprice(datainfo);
                }
            }
            if(shoufeilist2.size()>0){
                for (int i=0;i<shoufeilist2.size();i++){
                    //根据编码查询系统加急项
                    String praent_id = "";
                    AddSystemPriceInfo ceshidingdatainfo = formalCategoryInfoMapper.query_addsyspriceDetail(shoufeilist2.get(i).getPartentId());
                    if(ceshidingdatainfo!=null){
                        //查询新增的上级加急项
                        List<AddSystemPriceInfo> zsdingzhi_datalist = formalCategoryInfoMapper.query_AllsyspriceBypingleiId(plate_id,1);
                        if(zsdingzhi_datalist.size()>0){
                            for (int k=0;k<zsdingzhi_datalist.size();k++){
                                if(ceshidingdatainfo.getPremiumCode().equals(zsdingzhi_datalist.get(k).getPremiumCode())){
                                    praent_id = zsdingzhi_datalist.get(k).getId().toString();
                                    break;
                                }
                            }
                        }
                    }
                    //循环添加系统加急--下级
                    AddSystemPriceInfo datainfo = new AddSystemPriceInfo();
                    datainfo.setPremiumItem(shoufeilist2.get(i).getPremiumItem());
                    datainfo.setPremiumCode(shoufeilist2.get(i).getPremiumCode());
                    datainfo.setCategoryId(plate_id);
                    datainfo.setType(shoufeilist2.get(i).getType());
                    datainfo.setRemark(shoufeilist2.get(i).getRemark());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    datainfo.setPartentId(praent_id);//上级
                    datainfo.setIsTop(0);
                    datainfo.setNumbers(shoufeilist2.get(i).getNumbers());
                    code13 = formalCategoryInfoMapper.add_fomal_syspriceinfo(datainfo);
                }
            }
            /**
             * 定制项
             * */
            if (dingzhilist.size() > 0) {
               //执行删除测试的数据
               code1 = againEnabledMapper.real_delete_dingzhi(plate_id);
                for (int i = 0; i < dingzhilist.size(); i++) {
                    SmalltemplateTestInfo datainfo = new SmalltemplateTestInfo();
                    datainfo.setModuleId(dingzhilist.get(i).getModuleId());
                    datainfo.setCategoryId(plate_id);
                    datainfo.setCode(dingzhilist.get(i).getCode());
                    datainfo.setParameter(dingzhilist.get(i).getParameter());
                    datainfo.setImgs(dingzhilist.get(i).getImgs());
                    datainfo.setNumbers(dingzhilist.get(i).getNumbers());
                    datainfo.setIstype(dingzhilist.get(i).getIstype());
                    datainfo.setRemark(dingzhilist.get(i).getRemark());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    code1 = categoryInfoMapper.add_dingzhi(datainfo);
                }
            }
            /**
             * 定制项下的参数
             * */
            if (canshulist.size() > 0) {
                //执行删除测试的数据
                code2 = againEnabledMapper.real_delete_categorys(plate_id);
                for (int i = 0; i < canshulist.size(); i++) {
                    String praent_id = "";
                    SmalltemplateTestInfo ceshidingdatainfo = formalCategoryInfoMapper.query_dingzhiBydingzhId(canshulist.get(i).getParentId());
                    if (ceshidingdatainfo != null) {
                        //查询新增的定制项--测试版号
                        List<SmalltemplateTestInfo> zsdingzhi_datalist = testPlateInfoMapper.query_testdingzhiByBanhaoId(plate_id);
                        if (zsdingzhi_datalist.size() > 0) {
                            for (int j = 0; j < zsdingzhi_datalist.size(); j++) {
                                if (ceshidingdatainfo.getCode().equals(zsdingzhi_datalist.get(j).getCode())) {
                                    praent_id = zsdingzhi_datalist.get(j).getId().toString();
                                }
                            }
                        }
                    }
                    MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                    datainfo.setCategoryName(canshulist.get(i).getCategoryName());
                    datainfo.setCategoryCode(canshulist.get(i).getCategoryCode());
                    datainfo.setParentId(praent_id);
                    datainfo.setImg(canshulist.get(i).getImg());
                    datainfo.setTopid(plate_id);
                    datainfo.setNumbers(canshulist.get(i).getNumbers());
                    datainfo.setIsType(canshulist.get(i).getIsType());
                    datainfo.setCost(canshulist.get(i).getCost());
                    datainfo.setTeamPrice2(canshulist.get(i).getTeamPrice2());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    datainfo.setStatus(0);
                    code2 = categoryInfoMapper.add_dingzhi_canshu(datainfo);
                }
            }
            /**
             * 工艺模块
             * */
            if (gongyilist.size() > 0) {
                for (int i = 0; i < gongyilist.size(); i++) {
                    MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                    datainfo.setCategoryCode(gongyilist.get(i).getCategoryCode());
                    datainfo.setCategoryName(gongyilist.get(i).getCategoryName());
                    datainfo.setParentId("4");
                    datainfo.setImg(gongyilist.get(i).getImg());
                    datainfo.setRemark(gongyilist.get(i).getRemark());
                    datainfo.setTopid(plate_id);
                    datainfo.setIsType(4);
                    datainfo.setCategorySex(gongyilist.get(i).getCategorySex());
                    datainfo.setNumbers(gongyilist.get(i).getNumbers());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    datainfo.setStatus(0);
                    code3 = categoryInfoMapper.add_category_pinglei(datainfo);
                }
            }
            /**
             * 身体尺寸模块
             * */
            if (bodysizelist1.size() > 0) {
                //在增加前执行删除
                code4 = againEnabledMapper.real_delete_bodysize(plate_id);
                for (int i = 0; i < bodysizelist1.size(); i++) {
                    BodySizeTestInfo datainfo = new BodySizeTestInfo();
                    datainfo.setBodySizename(bodysizelist1.get(i).getBodySizename());
                    datainfo.setUnit(bodysizelist1.get(i).getUnit());
                    datainfo.setModuleId(bodysizelist1.get(i).getModuleId());
                    datainfo.setCategoryId(plate_id);
                    datainfo.setNumbers(bodysizelist1.get(i).getNumbers());
                    datainfo.setIsJin(bodysizelist1.get(i).getIsJin());
                    datainfo.setMax(bodysizelist1.get(i).getMax());
                    datainfo.setMin(bodysizelist1.get(i).getMin());
                    datainfo.setIsBitian(bodysizelist1.get(i).getIsBitian());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    datainfo.setCode(bodysizelist1.get(i).getCode());
                    code4 = categoryInfoMapper.add_testbodySize(datainfo);
                }
            }
            /**
             * 绣字部位
             * */
            if (xuzilist1.size() > 0) {
                //在增加前执行删除
                code5 = againEnabledMapper.real_delete_xiuzi_buwei(plate_id);
                for (int i = 0; i < xuzilist1.size(); i++) {
                    //执行添加
                    CategoryLocationTestInfo datainfo = new CategoryLocationTestInfo();
                    datainfo.setCode(xuzilist1.get(i).getCode());
                    datainfo.setXiuziLocaltion(xuzilist1.get(i).getXiuziLocaltion());
                    datainfo.setCategoryId(plate_id);
                    datainfo.setRemark(xuzilist1.get(i).getRemark());
                    datainfo.setNumbers(xuzilist1.get(i).getNumbers());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    datainfo.setStatus(0);
                    code5 = categoryInfoMapper.add_xiuzi_location(datainfo);
                }
            }
            /**
             * 绣字颜色
             * */
            if (xuzilist2.size() > 0) {
                //在增加前执行删除
                code6 = againEnabledMapper.real_delete_xiuzi_color(plate_id);
                for (int i = 0; i < xuzilist2.size(); i++) {
                    EmbroideredColorTestInfo datainfo = new EmbroideredColorTestInfo();
                    datainfo.setCode(xuzilist2.get(i).getCode());
                    datainfo.setColorName(xuzilist2.get(i).getColorName());
                    datainfo.setCategoryId(plate_id);
                    datainfo.setColorImg(xuzilist2.get(i).getColorImg());
                    datainfo.setNumbers(xuzilist2.get(i).getNumbers());
                    datainfo.setRemark(xuzilist2.get(i).getRemark());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    datainfo.setStatus(0);
                    code6 = categoryInfoMapper.add_xiuzi_color(datainfo);
                }
            }
            /**
             * 绣字字体或图片
             * */
            if (xuzilist3.size() > 0) {
                //在增加前执行删除
                code7 = againEnabledMapper.real_delete_xiuzi_fontImg(plate_id);
                for (int i = 0; i < xuzilist3.size(); i++) {
                    EmbroideredFontTestInfo datainfo = new EmbroideredFontTestInfo();
                    datainfo.setCode(xuzilist3.get(i).getCode());
                    datainfo.setEmbroideredName(xuzilist3.get(i).getEmbroideredName());
                    datainfo.setCategoryId(plate_id);
                    datainfo.setEmbroideredImage(xuzilist3.get(i).getEmbroideredImage());
                    datainfo.setNumbers(xuzilist3.get(i).getNumbers());
                    datainfo.setRemark(xuzilist3.get(i).getRemark());
                    datainfo.setIsZitiImg(xuzilist3.get(i).getIsZitiImg());
                    datainfo.setXiuziSize(xuzilist3.get(i).getXiuziSize());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    datainfo.setStatus(0);
                    code7 = categoryInfoMapper.add_xiuzi_fontImg(datainfo);
                }
            }
            /**
             * 返修模块
             * */
            if (fanxiulist.size() > 0) {
                //在增加前执行删除
                code8 = againEnabledMapper.real_delete_xiuzi_fanxiu(plate_id);
                for (int i = 0; i < fanxiulist.size(); i++) {
                    CategoryFanxiuTestInfo datainfo = new CategoryFanxiuTestInfo();
                    datainfo.setBodySizename(fanxiulist.get(i).getBodySizename());
                    datainfo.setUnit(fanxiulist.get(i).getUnit());
                    datainfo.setCategoryId(plate_id);
                    datainfo.setNumbers(fanxiulist.get(i).getNumbers());
                    datainfo.setMax(fanxiulist.get(i).getMax());
                    datainfo.setMin(fanxiulist.get(i).getMin());
                    datainfo.setRemark(fanxiulist.get(i).getRemark());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    datainfo.setCode(fanxiulist.get(i).getCode());
                    datainfo.setStatus(0);
                    code8 = categoryInfoMapper.add_testFanxiuSize(datainfo);
                }
            }

            /**
             * 撞色模块
             * */
            if (zhuangselist.size() > 0) {
                //执行删除测试的数据
                code9 = againEnabledMapper.real_delete_zhuangse(plate_id);
                for (int i = 0; i < zhuangselist.size(); i++) {
                    //查询新增的定制项
                    String dingzhi1 = "";
                    String firstId = "";
                    //根据品类id查询定制项
                    List<SmalltemplateTestInfo> zsdingzhi_datalist = categoryInfoMapper.query_dingzhiBycategoryId(plate_id);
                    SmalltemplateTestInfo ceshidingdatainfo1 = formalCategoryInfoMapper.query_dingzhiBydingzhId(zhuangselist.get(i).getDingzhiId());
                    if (ceshidingdatainfo1 != null) {
                        if (zsdingzhi_datalist.size() > 0) {
                            for (int j = 0; j < zsdingzhi_datalist.size(); j++) {
                                if (ceshidingdatainfo1.getCode().equals(zsdingzhi_datalist.get(j).getCode())) {
                                    dingzhi1 = zsdingzhi_datalist.get(j).getId().toString();
                                    break;
                                }
                            }
                        }
                    }
                    //根据类别id查询类别详情
                    MlccCategoryTestInfo leibiedatainfo1 = formalCategoryInfoMapper.select_testcategoryDetail(zhuangselist.get(i).getCategoryId());
                    if (leibiedatainfo1 != null) {
                        MlccCategoryInfo zsleibie = testPlateInfoMapper.select_zscategoryDetailByother(leibiedatainfo1.getCategoryCode(), plate_id, dingzhi1);
                        if (zsleibie != null) {
                            firstId = zsleibie.getId().toString();
                        }
                    }
                    //执行修改
                    ContrastcolorTestInfo datainfo = new ContrastcolorTestInfo();
                    datainfo.setTopId(plate_id);
                    datainfo.setCode(zhuangselist.get(i).getCode());
                    datainfo.setContrastColorName(zhuangselist.get(i).getContrastColorName());
                    datainfo.setCategoryId(firstId);
                    datainfo.setContrastColorImg(zhuangselist.get(i).getContrastColorImg());
                    datainfo.setSinglePrice2(zhuangselist.get(i).getSinglePrice2());
                    datainfo.setTeamPrice2(zhuangselist.get(i).getTeamPrice2());
                    datainfo.setDingzhiId(dingzhi1);
                    datainfo.setRemark(zhuangselist.get(i).getRemark());
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    code9 = categoryInfoMapper.add_zhuangse(datainfo);
                }
            }
            /**
             * 互斥项模块
             * */
            if (huchilist.size() > 0) {
                //执行删除测试的数据
                code10 = againEnabledMapper.real_delete_huchi(plate_id);
                for (int i = 0; i < huchilist.size(); i++) {
                    //查询新增的定制项
                    String dingzhi1 = "", dingzhi2 = "";
                    String firstId = "", secoundId = "";
                    //根据品类id查询定制项
                    List<SmalltemplateTestInfo> zsdingzhi_datalist = categoryInfoMapper.query_dingzhiBycategoryId(plate_id);

                    SmalltemplateTestInfo ceshidingdatainfo1 = formalCategoryInfoMapper.query_dingzhiBydingzhId(huchilist.get(i).getDingzhi1());
                    SmalltemplateTestInfo ceshidingdatainfo2 = formalCategoryInfoMapper.query_dingzhiBydingzhId(huchilist.get(i).getDingzhi2());
                    if (ceshidingdatainfo1 != null) {
                        if (zsdingzhi_datalist.size() > 0) {
                            for (int j = 0; j < zsdingzhi_datalist.size(); j++) {
                                if (ceshidingdatainfo1.getCode().equals(zsdingzhi_datalist.get(j).getCode())) {
                                    dingzhi1 = zsdingzhi_datalist.get(j).getId().toString();
                                    break;
                                }
                            }
                        }
                    }
                    if (ceshidingdatainfo2 != null) {
                        if (zsdingzhi_datalist.size() > 0) {
                            for (int f = 0; f < zsdingzhi_datalist.size(); f++) {
                                if (ceshidingdatainfo2.getCode().equals(zsdingzhi_datalist.get(f).getCode())) {
                                    dingzhi2 = zsdingzhi_datalist.get(f).getId().toString();
                                    break;
                                }
                            }
                        }
                    }
                    //根据类别id查询类别详情
                    MlccCategoryTestInfo leibiedatainfo1 = formalCategoryInfoMapper.select_testcategoryDetail(huchilist.get(i).getCategoryId());
                    if (leibiedatainfo1 != null) {
                        MlccCategoryInfo zsleibie = testPlateInfoMapper.select_zscategoryDetailByother(leibiedatainfo1.getCategoryCode(), plate_id, dingzhi1);
                        if (zsleibie != null) {
                            firstId = zsleibie.getId().toString();
                        }
                    }
                    String canshuids[] = huchilist.get(i).getCategoryOther().split(",");
                    System.out.println("其他参数==" + huchilist.get(i).getCategoryOther() + "==" + dingzhi2);
                    String strbody = "";
                    for (String s : canshuids) {
                        //根据类别id查询类别详情
                        MlccCategoryTestInfo leibiedatainfo2 = formalCategoryInfoMapper.select_testcategoryDetail(s);
                        if (leibiedatainfo2 != null) {
                            MlccCategoryInfo zsleibie = testPlateInfoMapper.select_zscategoryDetailByother(leibiedatainfo2.getCategoryCode(), plate_id, dingzhi2);
                            if (zsleibie != null) {
                                strbody += zsleibie.getId().toString() + ",";
                            }
                        }
                    }
                    if (strbody == null || "".equals(strbody)) {
                        secoundId = "";
                    } else {
                        secoundId = strbody.substring(0, strbody.length() - 1);
                    }
                    //执行修改
                    MutexTestInfo datainfo = new MutexTestInfo();
                    datainfo.setMutexName(huchilist.get(i).getMutexName());
                    datainfo.setTopId(plate_id);
                    datainfo.setCategoryId(firstId);
                    datainfo.setCategoryOther(secoundId);
                    datainfo.setMutexReason(huchilist.get(i).getMutexReason());
                    datainfo.setStatus(huchilist.get(i).getStatus());
                    datainfo.setCode(huchilist.get(i).getCode());
                    datainfo.setDingzhi1(dingzhi1);
                    datainfo.setDingzhi2(dingzhi2);
                    datainfo.setSysOrgCode(sys_org_code);
                    datainfo.setCreateBy(create_by);
                    code10 = categoryInfoMapper.add_huchi(datainfo);
                }
            }
            Long end_time = System.currentTimeMillis();
            System.out.println("最终还原数据输出时间：" + (end_time - start_time));
            System.out.println("各个code==" + code1 + "==" + code2 + "=" + code3 + "=" + code4 + "=" + code5 + "=" + code6 + "=" + code7 + "=" + code8 + "=" + code9 + "=" + code10);
            if (code1 > 0 || code2 > 0 || code3 > 0 || code4 > 0 || code5 > 0 || code6 > 0 || code7 > 0 || code8 > 0 || code9 > 0 || code10 > 0 || code11>0 || code12>0 || code13>0) {
                //测试区
                formalCategoryInfoMapper.add_qiyong_record(plate_id,"0","1",pingleiName+"被还原成草稿件",create_by,sys_org_code);
                //正式插入记录
                formalCategoryInfoMapper.add_qiyong_record(formal_categoryId,"0","1",pingleiName+"已还原成草稿件",create_by,sys_org_code);
                return 0;
            } else {
                return 1;
            }
        }else {
            return 2;
        }
    }


    /**
     * 启用版号草稿件
     * @param category_id 测试版号ID
     */
    @Override
    public int enabled_plate_caogao(String category_id) {
        //获取登录用户信息
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String sys_org_code = sysUser.getOrgCode();
        String create_by = sysUser.getUsername();
        //声明正式的品类id和名称
        String zhengshi_categoryId="",zhengshi_categoryName="";
        //根据测试品类id查询品类
        MlccCategoryTestInfo testcategoryDetail = againEnabledMapper.query_categoryDetailByid(category_id);
        MlccCategoryInfo zsCategoryDetail = againEnabledMapper.select_zscategoryDetail(testcategoryDetail.getCategoryCode());
        if(zsCategoryDetail != null){//再次启用
            //先判断该品类是否上架
            if(zsCategoryDetail.getStatus()==0){
                return 2;//请先下架再启用
            }else {
                int code2 = 0,code3=0,code4=0,code5=0,code6=0,code7=0,code8=0,code9=0,code10=0,code66=0,code11=0,code67=0,code666=0;
                Long startTs1 = System.currentTimeMillis(); // 当前时间戳
                /**正式品类id下的参数*/
                String formalcategory_id = zsCategoryDetail.getId().toString();
                zhengshi_categoryName = zsCategoryDetail.getCategoryName();
                //根据测试版号id查询所有的数据
                //根据品类id查询定制项
                List<SmalltemplateTestInfo> dingzhilist = againEnabledMapper.query_dingzhiBytopId(category_id);
                //根据品类id查询定制项下的参数
                List<MlccCategoryTestInfo> canshulist = againEnabledMapper.query_dingzhi_canshuBytopId(category_id);
                //根据品类id查询互斥项
                List<MutexTestInfo> huchilist = againEnabledMapper.query_mutextBytopId(category_id);
                //根据品类id查询绣字部位
                List<CategoryLocationTestInfo> xuzilist1 = againEnabledMapper.query_LocationBytopId(category_id);
                //根据品类id查询绣字颜色
                List<EmbroideredColorTestInfo> xuzilist2 = againEnabledMapper.query_EmbroideredColorBytopId(category_id);
                //根据品类id查询绣字图片
                List<EmbroideredFontTestInfo> xuzilist3 = againEnabledMapper.query_EmbroideredFontBytopId(category_id);
                //根据品类id查询撞色
                List<ContrastcolorTestInfo> zhuangselist = againEnabledMapper.query_ContrastcolorBytopId(category_id);
//                根据品类id查询净体尺寸-查全部
//                List<BodySizeTestInfo> bodysizelist1 = againEnabledMapper.query_BodySizeBytopId(category_id);
                //根据品类id查询净体尺寸-查询现在
                List<BodySizeTestInfo> bodysizelist1 = formalCategoryInfoMapper.query_AlljingtiBodysizeBypingleiId(category_id);

                //根据品类id查询返修
                List<CategoryFanxiuTestInfo> fanxiulist = againEnabledMapper.query_CategoryFanxiuBytopId(category_id);
                //根据品类id查询工艺类型
                List<MlccCategoryTestInfo> gongyilist = againEnabledMapper.query_MlccCategoryBytopId(category_id);
                //根据品类id查询所有系统加急
                List<AddSystemPriceInfo> syspricelist = againEnabledMapper.query_AddSystemPriceBytopId(category_id,1);
                List<AddSystemPriceInfo> syspricelist2 = againEnabledMapper.query_AddSystemPriceBytopId(category_id,0);
                //根据品类id查询所有绣字高度-测试
                List<EmbroidedHeightInfo> xiuziHeightlist = againEnabledMapper.query_EmbroidedHeightBytopId(category_id);
                //根据版号id查询测试的辅料
                List<CategoryMaterialInfo> fuliaolist = formalPlateInfoMapper.query_AllfuliaoBypingleiId(category_id);
                //根据版号id查询测试的标准码
                List<StandardCodeInfo> standcodelist = testPlateInfoMapper.query_standardCodelist(category_id,2);


                //根据版号id查询正式的辅料
                List<CategoryMaterialInfo> test_fuliaolist = testPlateInfoMapper.query_AllfuliaoBypingleiId2(formalcategory_id);
                //根据版号id查询正式的标准码
                List<StandardCodeInfo> test_standcodelist = testPlateInfoMapper.query_standardCodelist(formalcategory_id,1);
                if (test_fuliaolist.size() > 0) {
                    //循环删除正式的辅料
                    int code = 0;
                    for (CategoryMaterialInfo testobject : test_fuliaolist) {
                        code = formalPlateInfoMapper.delete_plate_libu(testobject.getId().toString());
                    }
                    System.out.println("删除正式的辅料==" + code);
                }
                if (test_standcodelist.size() > 0) {
                    //循环删除正式的标准码
                    int code = 0;
                    for (StandardCodeInfo testobject : test_standcodelist) {
                        code = testPlateInfoMapper.delete_StandardCode_zhengshi(testobject.getId());
                    }
                    System.out.println("删除正式的标准码==" + code);
                }

                if(dingzhilist.size()>0){
                    for (int i = 0;i<dingzhilist.size();i++){
                        if(dingzhilist.get(i).getStatus()!=0){//假删除
                            //根据编号删除正式的定制项
                            code2 = againEnabledMapper.delete_zsDingzhiByCodeplate(dingzhilist.get(i).getCode(),formalcategory_id);
                            System.out.println("删除成功=="+code2);
                            //根据品类id和编号查询当前没有删除的数据--仅仅只有一个
                            SmalltemplateTestInfo zs_datadetail = againEnabledMapper.query_dingzhitailByCode(dingzhilist.get(i).getCode(),category_id,3);
                            if(zs_datadetail!=null){
                                //执行添加
                                SmalltemplateTestInfo datainfo = new SmalltemplateTestInfo();
                                datainfo.setModuleId(zs_datadetail.getModuleId());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setCode(zs_datadetail.getCode());
                                datainfo.setParameter(zs_datadetail.getParameter());
                                datainfo.setImgs(zs_datadetail.getImgs());
                                datainfo.setNumbers(zs_datadetail.getNumbers());
                                datainfo.setIstype(zs_datadetail.getIstype());
                                datainfo.setRemark(zs_datadetail.getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code2 = formalCategoryInfoMapper.add_dingzhi(datainfo);
                            }
                        }else {//没删
                            //根据编号查询正式的定制项有没有，如果有就执行修改，没有就执行添加
                            SmalltemplateTestInfo zsdingzhiDetail = againEnabledMapper.query_zsDingzhiDetailByCodeplate(dingzhilist.get(i).getCode(),formalcategory_id);
                            if(zsdingzhiDetail != null){
                                //执行修改
                                SmalltemplateTestInfo datainfo = new SmalltemplateTestInfo();
                                datainfo.setCode(dingzhilist.get(i).getCode());
                                datainfo.setParameter(dingzhilist.get(i).getParameter());
                                datainfo.setNumbers(dingzhilist.get(i).getNumbers());
                                datainfo.setRemark(dingzhilist.get(i).getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setUpdateBy(create_by);
                                datainfo.setId(zsdingzhiDetail.getId());
                                code2 = formalCategoryInfoMapper.change_dingzhi(datainfo);
                            }else {
                                //执行添加
                                SmalltemplateTestInfo datainfo = new SmalltemplateTestInfo();
                                datainfo.setModuleId(dingzhilist.get(i).getModuleId());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setCode(dingzhilist.get(i).getCode());
                                datainfo.setParameter(dingzhilist.get(i).getParameter());
                                datainfo.setImgs(dingzhilist.get(i).getImgs());
                                datainfo.setNumbers(dingzhilist.get(i).getNumbers());
                                datainfo.setIstype(dingzhilist.get(i).getIstype());
                                datainfo.setRemark(dingzhilist.get(i).getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code2 = formalCategoryInfoMapper.add_dingzhi(datainfo);
                            }
                        }
                    }
                }
                /**
                 * 定制项下的参数
                 */
                if (canshulist.size() > 0) {
                    for (int i = 0; i < canshulist.size(); i++) {
                        if (canshulist.get(i).getStatus() != 0) {//假删除
                            String praent_id = "";//获取他的上级
                            SmalltemplateTestInfo ceshidingdatainfo = categoryInfoMapper.query_dingzhiBydingzhId(canshulist.get(i).getParentId());
                            if (ceshidingdatainfo != null) {
                                //查询新增的定制项
                                List<SmalltemplateTestInfo> zsdingzhi_datalist = formalCategoryInfoMapper.query_dingzhiBycategoryId(formalcategory_id);
                                if (zsdingzhi_datalist.size() > 0) {
                                    for (int k = 0; k < zsdingzhi_datalist.size(); k++) {
                                        if (ceshidingdatainfo.getCode().equals(zsdingzhi_datalist.get(k).getCode())) {
                                            praent_id = zsdingzhi_datalist.get(k).getId().toString();
                                        }
                                    }
                                }
                            }
                            //根据编号和上级id删除正式的定制项下的参数
                            code3 = againEnabledMapper.delete_zsDingzhi_canshuByCode(canshulist.get(i).getCategoryCode(), praent_id, formalcategory_id);
                            System.out.println("删除成功==" + code3);
                            //根据品类id和编号查询当前没有删除的数据--仅仅只有一个
                            MlccCategoryTestInfo zs_datadetail = againEnabledMapper.query_dingzhi_canshutailByCode2(canshulist.get(i).getCategoryCode(),category_id,canshulist.get(i).getParentId());
                            if(zs_datadetail!=null){
                                String praent_id2 = "";//获取他的上级
                                SmalltemplateTestInfo ceshidingdatainfo2 = categoryInfoMapper.query_dingzhiBydingzhId(zs_datadetail.getParentId());
                                if (ceshidingdatainfo2 != null) {
                                    //查询新增的定制项
                                    List<SmalltemplateTestInfo> zsdingzhi_datalist = formalCategoryInfoMapper.query_dingzhiBycategoryId(formalcategory_id);
                                    if (zsdingzhi_datalist.size() > 0) {
                                        for (int k = 0; k < zsdingzhi_datalist.size(); k++) {
                                            if (ceshidingdatainfo.getCode().equals(zsdingzhi_datalist.get(k).getCode())) {
                                                praent_id2 = zsdingzhi_datalist.get(k).getId().toString();
                                            }
                                        }
                                    }
                                }
                                System.out.println("走的添加参数111==="+praent_id2+"==="+formalcategory_id);
                                //执行添加
                                MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                                datainfo.setCategoryName(zs_datadetail.getCategoryName());
                                datainfo.setCategoryCode(zs_datadetail.getCategoryCode());
                                datainfo.setParentId(praent_id2);//正式的上级id
                                datainfo.setImg(zs_datadetail.getImg());
                                datainfo.setTopid(formalcategory_id);
                                datainfo.setNumbers(zs_datadetail.getNumbers());
                                datainfo.setIsType(0);
                                datainfo.setCost("0");
                                datainfo.setTeamPrice2("0");
                                datainfo.setStatus(0);
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code3 = formalCategoryInfoMapper.add_dingzhi_canshu(datainfo);
                            }

                        } else {//没删
                            String praent_id3 = "";//获取他的上级
                            SmalltemplateTestInfo ceshidingdatainfo = categoryInfoMapper.query_dingzhiBydingzhId(canshulist.get(i).getParentId());
                            if (ceshidingdatainfo != null) {
                                //查询新增的定制项
                                List<SmalltemplateTestInfo> zsdingzhi_datalist3 = formalCategoryInfoMapper.query_dingzhiBycategoryId(formalcategory_id);
                                if (zsdingzhi_datalist3.size() > 0) {
                                    for (int k = 0; k < zsdingzhi_datalist3.size(); k++) {
                                        if (ceshidingdatainfo.getCode().equals(zsdingzhi_datalist3.get(k).getCode())) {
                                            praent_id3 = zsdingzhi_datalist3.get(k).getId().toString();
                                        }
                                    }
                                }
                            }
                            //根据编号查询正式的定制项有没有，如果有就执行修改，没有就执行添加
                            MlccCategoryInfo zscanshuDetail = againEnabledMapper.query_zscanshuDetailByCode(canshulist.get(i).getCategoryCode(), praent_id3, formalcategory_id);
                            if (zscanshuDetail != null) {
                                //执行修改
                                System.out.println("走的修改参数==="+praent_id3+"==="+formalcategory_id);
                                MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                                datainfo.setCategoryName(canshulist.get(i).getCategoryName());
                                datainfo.setCategoryCode(canshulist.get(i).getCategoryCode());
                                datainfo.setParentId(praent_id3);//正式的上级id
                                datainfo.setImg(canshulist.get(i).getImg());
                                datainfo.setTopid(formalcategory_id);
                                datainfo.setNumbers(canshulist.get(i).getNumbers());
                                datainfo.setIsType(0);
                                datainfo.setStatus(0);
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setUpdateBy(create_by);
                                datainfo.setId(zscanshuDetail.getId());
                                code3 = formalCategoryInfoMapper.change_dingzhi_canshu(datainfo);
                            } else {
                                System.out.println("走的添加参数啊==="+praent_id3+"==="+formalcategory_id);
                                //执行添加
                                MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                                datainfo.setCategoryName(canshulist.get(i).getCategoryName());
                                datainfo.setCategoryCode(canshulist.get(i).getCategoryCode());
                                datainfo.setParentId(praent_id3);//正式的上级id
                                datainfo.setImg(canshulist.get(i).getImg());
                                datainfo.setTopid(formalcategory_id);
                                datainfo.setNumbers(canshulist.get(i).getNumbers());
                                datainfo.setIsType(0);
                                datainfo.setCost("0");
                                datainfo.setTeamPrice2("0");
                                datainfo.setStatus(0);
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code3 = formalCategoryInfoMapper.add_dingzhi_canshu(datainfo);
                            }
                        }
                    }
                }
                /**
                 * 品类下的互斥
                 */
                if (huchilist.size() > 0) {
                    //执行先删除下面所有互斥
//                    againEnabledMapper.delete_zshuchiByTopId(formalcategory_id);
                    for (int i = 0; i < huchilist.size(); i++) {
                        if (huchilist.get(i).getStatus() == 3) {//假删除
                            //根据编号和上级id删除正式的定制项下的参数
                            code4 = againEnabledMapper.delete_zshuchiByCodeplate(huchilist.get(i).getCode(), formalcategory_id);
                            System.out.println("删除互斥成功==" + code4);
                        } else {//没删
                            //查询新增的定制项
                            String dingzhi1 = "", dingzhi2 = "";
                            String firstId = "", secoundId = "";
                            List<SmalltemplateTestInfo> zsdingzhi_datalist = formalCategoryInfoMapper.query_dingzhiBycategoryId(formalcategory_id);
                            SmalltemplateTestInfo ceshidingdatainfo1 = categoryInfoMapper.query_dingzhiBydingzhId(huchilist.get(i).getDingzhi1());
                            SmalltemplateTestInfo ceshidingdatainfo2 = categoryInfoMapper.query_dingzhiBydingzhId(huchilist.get(i).getDingzhi2());
                            if (ceshidingdatainfo1 != null) {
                                if (zsdingzhi_datalist.size() > 0) {
                                    for (int k = 0; k < zsdingzhi_datalist.size(); k++) {
                                        if (ceshidingdatainfo1.getCode().equals(zsdingzhi_datalist.get(k).getCode())) {
                                            dingzhi1 = zsdingzhi_datalist.get(k).getId().toString();
                                            break;
                                        }
                                    }
                                }
                            }
                            if (ceshidingdatainfo2 != null) {
                                if (zsdingzhi_datalist.size() > 0) {
                                    for (int k = 0; k < zsdingzhi_datalist.size(); k++) {
                                        if (ceshidingdatainfo2.getCode().equals(zsdingzhi_datalist.get(k).getCode())) {
                                            dingzhi2 = zsdingzhi_datalist.get(k).getId().toString();
                                            break;
                                        }
                                    }
                                }
                            }
                            //根据类别id查询类别详情
                            MlccCategoryTestInfo leibiedatainfo1 = categoryInfoMapper.select_testcategoryDetail(huchilist.get(i).getCategoryId());
                            if (leibiedatainfo1 != null) {
                                MlccCategoryInfo zsleibie = formalCategoryInfoMapper.select_zscategoryDetailByother(leibiedatainfo1.getCategoryCode(), formalcategory_id, dingzhi1);
                                if (zsleibie != null) {
                                    firstId = zsleibie.getId().toString();
                                }
                            }
                            String canshuids[] = huchilist.get(i).getCategoryOther().split(",");
                            String strbody = "";
                            for (String s : canshuids) {
                                //根据类别id查询类别详情
                                MlccCategoryTestInfo leibiedatainfo2 = categoryInfoMapper.select_testcategoryDetail(s);
                                if (leibiedatainfo2 != null) {
                                    MlccCategoryInfo zsleibie = formalCategoryInfoMapper.select_zscategoryDetailByother(leibiedatainfo2.getCategoryCode(), formalcategory_id, dingzhi2);
                                    if (zsleibie != null) {
                                        strbody += zsleibie.getId().toString() + ",";
                                    }
                                }
                            }
                            if(strbody==null || "".equals(strbody)){
                                secoundId = "";
                            }else {
                                secoundId = strbody.substring(0,strbody.length()-1);
                            }

                            //根据编号查询正式的定制项有没有，如果有就执行修改，没有就执行添加
                            MutexTestInfo zscanshuDetail = againEnabledMapper.query_zshuchiByCode(huchilist.get(i).getCode(), formalcategory_id);
                            if (zscanshuDetail != null) {
                                //循环修改互斥
                                MutexTestInfo datainfo = new MutexTestInfo();
                                datainfo.setMutexName(huchilist.get(i).getMutexName());
                                datainfo.setCategoryId(firstId);//第一个参数id
                                datainfo.setCategoryOther(secoundId);//第二个参数id
                                datainfo.setMutexReason(huchilist.get(i).getMutexReason());
                                datainfo.setStatus(huchilist.get(i).getStatus());
                                datainfo.setDingzhi1(dingzhi1);
                                datainfo.setDingzhi2(dingzhi2);
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setUpdateBy(create_by);
                                datainfo.setId(zscanshuDetail.getId());
                                code4 = againEnabledMapper.change_zshuchiById(datainfo);
                            } else {
                                //循环添加互斥
                                MutexTestInfo datainfo = new MutexTestInfo();
                                datainfo.setMutexName(huchilist.get(i).getMutexName());
                                datainfo.setTopId(formalcategory_id);
                                datainfo.setCategoryId(firstId);//第一个参数id
                                datainfo.setCategoryOther(secoundId);//第二个参数id
                                datainfo.setMutexReason(huchilist.get(i).getMutexReason());
                                datainfo.setStatus(huchilist.get(i).getStatus());
                                datainfo.setCode(huchilist.get(i).getCode());
                                datainfo.setDingzhi1(dingzhi1);
                                datainfo.setDingzhi2(dingzhi2);
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code4 = formalCategoryInfoMapper.add_huchi(datainfo);
                            }
                        }
                    }
                }


                if (xuzilist1.size() > 0) {
                    //先执行根据正式品类id删除全部
//                    againEnabledMapper.delete_zs_xiuzilocaltionByTopId(formalcategory_id);
                    for (int i = 0; i < xuzilist1.size(); i++) {
                        if (xuzilist1.get(i).getStatus() != 0) {//假删除
                            //根据编号删除正式的绣字部位
                            code5 = againEnabledMapper.delete_zsxiuziLocationByCodeplate(xuzilist1.get(i).getCode(), formalcategory_id);
                            System.out.println("删除成功==" + code5);
                            //根据品类id和编号查询当前没有删除的数据--仅仅只有一个
                            CategoryLocationTestInfo zs_datadetail = againEnabledMapper.query_xiuzibuweietailByCode(xuzilist1.get(i).getCode(),category_id,3);
                            if(zs_datadetail!=null){
                                //执行添加
                                CategoryLocationTestInfo datainfo = new CategoryLocationTestInfo();
                                datainfo.setCode(zs_datadetail.getCode());
                                datainfo.setXiuziLocaltion(zs_datadetail.getXiuziLocaltion());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setRemark(zs_datadetail.getRemark());
                                datainfo.setNumbers(zs_datadetail.getNumbers());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                datainfo.setStatus(0);
                                code5 = formalCategoryInfoMapper.add_xiuzi_location(datainfo);
                            }
                        } else {//没删
                            //根据编号查询正式的绣字部位有没有，如果有就执行修改，没有就执行添加
                            CategoryLocationTestInfo zsdingzhiDetail = againEnabledMapper.query_zsxiuziLocationByCode(xuzilist1.get(i).getCode(), formalcategory_id);
                            if (zsdingzhiDetail != null) {
                                //循环修改绣字部位
                                CategoryLocationTestInfo datainfo = new CategoryLocationTestInfo();
//                                datainfo.setCode(xuzilist1.get(i).getCode());
                                datainfo.setXiuziLocaltion(xuzilist1.get(i).getXiuziLocaltion());
                                datainfo.setRemark(xuzilist1.get(i).getRemark());
                                datainfo.setNumbers(xuzilist1.get(i).getNumbers());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setUpdateBy(create_by);
                                datainfo.setId(zsdingzhiDetail.getId());
                                code5 = againEnabledMapper.change_zsxiuziLocationById(datainfo);
                            } else {
                                //循环添加绣字部位
                                CategoryLocationTestInfo datainfo = new CategoryLocationTestInfo();
                                datainfo.setCode(xuzilist1.get(i).getCode());
                                datainfo.setXiuziLocaltion(xuzilist1.get(i).getXiuziLocaltion());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setRemark(xuzilist1.get(i).getRemark());
                                datainfo.setNumbers(xuzilist1.get(i).getNumbers());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code5 = formalCategoryInfoMapper.add_xiuzi_location(datainfo);
                            }
                        }

                    }
                }
                if (xuzilist2.size() > 0) {
                    //先执行根据正式品类id删除全部
//                    againEnabledMapper.delete_zs_xiuzicolorByTopId(formalcategory_id);
                    for (int i = 0; i < xuzilist2.size(); i++) {
                        if (xuzilist2.get(i).getStatus() != 0) {//假删除
                            //根据编号删除正式的绣字部位
                            code6 = againEnabledMapper.delete_zsxiuziColorByCodeplate(xuzilist2.get(i).getCode(), formalcategory_id);
                            System.out.println("删除成功==" + code6);
                            //根据品类id和编号查询当前没有删除的数据--仅仅只有一个
                            EmbroideredColorTestInfo zs_datadetail = againEnabledMapper.query_xiuziColortailByCode(xuzilist2.get(i).getCode(),category_id,3);
                            if(zs_datadetail!=null){
                                //循环添加绣字颜色
                                EmbroideredColorTestInfo datainfo = new EmbroideredColorTestInfo();
                                datainfo.setCode(zs_datadetail.getCode());
                                datainfo.setColorName(zs_datadetail.getColorName());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setColorImg(zs_datadetail.getColorImg());
                                datainfo.setRemark(zs_datadetail.getRemark());
                                datainfo.setNumbers(zs_datadetail.getNumbers());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code6 = formalCategoryInfoMapper.add_xiuzi_color(datainfo);
                            }
                        } else {//没删
                            //根据编号查询正式的绣字部位有没有，如果有就执行修改，没有就执行添加
                            EmbroideredColorTestInfo zsdingzhiDetail = againEnabledMapper.query_zsxiuziColorByCode(xuzilist2.get(i).getCode(), formalcategory_id);
                            if (zsdingzhiDetail != null) {
                                //循环修改绣字颜色
                                EmbroideredColorTestInfo datainfo = new EmbroideredColorTestInfo();
                                datainfo.setColorName(xuzilist2.get(i).getColorName());
                                datainfo.setColorImg(xuzilist2.get(i).getColorImg());
                                datainfo.setRemark(xuzilist2.get(i).getRemark());
                                datainfo.setNumbers(xuzilist2.get(i).getNumbers());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setUpdateBy(create_by);
                                datainfo.setId(zsdingzhiDetail.getId());
                                code6 = againEnabledMapper.change_zsxiuziColorById(datainfo);
                            } else {
                                //循环添加绣字颜色
                                EmbroideredColorTestInfo datainfo = new EmbroideredColorTestInfo();
                                datainfo.setCode(xuzilist2.get(i).getCode());
                                datainfo.setColorName(xuzilist2.get(i).getColorName());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setColorImg(xuzilist2.get(i).getColorImg());
                                datainfo.setRemark(xuzilist2.get(i).getRemark());
                                datainfo.setNumbers(xuzilist2.get(i).getNumbers());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code6 = formalCategoryInfoMapper.add_xiuzi_color(datainfo);
                            }
                        }
                    }
                }
                if (xuzilist3.size() > 0) {
                    //先执行根据正式品类id删除全部
                    againEnabledMapper.delete_zs_xiuzifontByTopId(formalcategory_id);
                    for (int i = 0; i < xuzilist3.size(); i++) {
                        if (xuzilist3.get(i).getStatus() == 0) {//非假删除
                            //循环添加绣字字体
                            EmbroideredFontTestInfo datainfo = new EmbroideredFontTestInfo();
                            datainfo.setCode(xuzilist3.get(i).getCode());
                            datainfo.setEmbroideredName(xuzilist3.get(i).getEmbroideredName());
                            datainfo.setCategoryId(formalcategory_id);
                            datainfo.setEmbroideredImage(xuzilist3.get(i).getEmbroideredImage());
                            datainfo.setRemark(xuzilist3.get(i).getRemark());
                            datainfo.setNumbers(xuzilist3.get(i).getNumbers());
                            datainfo.setIsZitiImg(xuzilist3.get(i).getIsZitiImg());
                            datainfo.setXiuziSize(xuzilist3.get(i).getXiuziSize());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code66 = formalCategoryInfoMapper.add_xiuzi_fontImg(datainfo);
                        }

//                        if(xuzilist3.get(i).getStatus()!=0){//假删除
//                            //根据编号删除正式的绣字部位
//                            code66 = againEnabledMapper.delete_zsxiuziFontByCodeplate(xuzilist3.get(i).getCode(),formalcategory_id);
//                            System.out.println("删除成功=="+code66);
//                        }else {//没删
//                            //根据编号查询正式的绣字部位有没有，如果有就执行修改，没有就执行添加
//                            EmbroideredFontTestInfo zsdingzhiDetail = againEnabledMapper.query_zsxiuziFontByCode(xuzilist3.get(i).getCode(),formalcategory_id);
//                            if(zsdingzhiDetail != null){
//                                EmbroideredFontTestInfo datainfo = new EmbroideredFontTestInfo();
//                                datainfo.setEmbroideredName(xuzilist3.get(i).getEmbroideredName());
//                                datainfo.setEmbroideredImage(xuzilist3.get(i).getEmbroideredImage());
//                                datainfo.setRemark(xuzilist3.get(i).getRemark());
//                                datainfo.setNumbers(xuzilist3.get(i).getNumbers());
//                                datainfo.setIsZitiImg(xuzilist3.get(i).getIsZitiImg());
//                                datainfo.setXiuziSize(xuzilist3.get(i).getXiuziSize());
//                                datainfo.setSysOrgCode(sys_org_code);
//                                datainfo.setUpdateBy(create_by);
//                                datainfo.setId(zsdingzhiDetail.getId());
//                                code66 = againEnabledMapper.change_zsxiuziFontById(datainfo);
//                            }else {
//                                //循环添加绣字字体
//                                EmbroideredFontTestInfo datainfo = new EmbroideredFontTestInfo();
//                                datainfo.setCode(xuzilist3.get(i).getCode());
//                                datainfo.setEmbroideredName(xuzilist3.get(i).getEmbroideredName());
//                                datainfo.setCategoryId(formalcategory_id);
//                                datainfo.setEmbroideredImage(xuzilist3.get(i).getEmbroideredImage());
//                                datainfo.setRemark(xuzilist3.get(i).getRemark());
//                                datainfo.setNumbers(xuzilist3.get(i).getNumbers());
//                                datainfo.setIsZitiImg(xuzilist3.get(i).getIsZitiImg());
//                                datainfo.setXiuziSize(xuzilist3.get(i).getXiuziSize());
//                                datainfo.setSysOrgCode(sys_org_code);
//                                datainfo.setCreateBy(create_by);
//                                code66 = formalCategoryInfoMapper.add_xiuzi_fontImg(datainfo);
//                            }
//                        }
                    }
                }


                if(xiuziHeightlist.size()>0){
                    //先执行根据正式品类id删除全部
                    againEnabledMapper.delete_zs_xiuziHeightByTopId(formalcategory_id);
                    for (int i=0;i<xiuziHeightlist.size();i++){
                        //循环添加绣字高度
                        EmbroidedHeightInfo datainfo = new EmbroidedHeightInfo();
                        datainfo.setEmbroideredHeight(xiuziHeightlist.get(i).getEmbroideredHeight());
                        datainfo.setHeightCode(xiuziHeightlist.get(i).getHeightCode());
                        datainfo.setCategoryId(formalcategory_id);
                        datainfo.setRemark(xiuziHeightlist.get(i).getRemark());
                        datainfo.setSysOrgCode(sys_org_code);
                        datainfo.setCreateBy(create_by);
                        code67 = testPlateInfoMapper.add_xiuzi_height(datainfo);
                    }
                }

                if (bodysizelist1.size() > 0) {
                    //先执行根据正式品类id删除全部
                    againEnabledMapper.delete_zs_bodysizeByTopId(formalcategory_id);
                    for (int i = 0; i < bodysizelist1.size(); i++) {
                        //循环添加身体尺寸
                        BodySizeTestInfo datainfo = new BodySizeTestInfo();
                        datainfo.setBodySizename(bodysizelist1.get(i).getBodySizename());
                        datainfo.setUnit(bodysizelist1.get(i).getUnit());
                        datainfo.setModuleId(bodysizelist1.get(i).getModuleId());
                        datainfo.setCategoryId(formalcategory_id);
                        datainfo.setNumbers(bodysizelist1.get(i).getNumbers());
                        datainfo.setIsJin(bodysizelist1.get(i).getIsJin());
                        datainfo.setMax(bodysizelist1.get(i).getMax());
                        datainfo.setMin(bodysizelist1.get(i).getMin());
                        datainfo.setIsBitian(bodysizelist1.get(i).getIsBitian());
                        datainfo.setSysOrgCode(sys_org_code);
                        datainfo.setCreateBy(create_by);
                        datainfo.setCode(bodysizelist1.get(i).getCode());
                        code8 = formalCategoryInfoMapper.add_testbodySize(datainfo);
                    }
//                    for (int i = 0; i < bodysizelist1.size(); i++) {
//                        if (bodysizelist1.get(i).getStatus() != 0) {//假删除
//                            if(bodysizelist1.get(i).getCode()==null || "".equals(bodysizelist1.get(i).getCode())){
//
//                            }else {
//                                //根据编号删除正式的绣字部位
//                                code66 = againEnabledMapper.delete_zsbodysizeByCodeplate(bodysizelist1.get(i).getCode(), formalcategory_id);
//                                System.out.println("删除成功==" + code66);
//                                BodySizeTestInfo zsdingzhiDetail = againEnabledMapper.query_testbodysizeByCode(bodysizelist1.get(i).getCode(), category_id);
//                                if(zsdingzhiDetail!=null){
//                                    //循环添加身体尺寸
//                                    BodySizeTestInfo datainfo = new BodySizeTestInfo();
//                                    datainfo.setBodySizename(zsdingzhiDetail.getBodySizename());
//                                    datainfo.setUnit(zsdingzhiDetail.getUnit());
//                                    datainfo.setModuleId(zsdingzhiDetail.getModuleId());
//                                    datainfo.setCategoryId(formalcategory_id);
//                                    datainfo.setNumbers(zsdingzhiDetail.getNumbers());
//                                    datainfo.setIsJin(zsdingzhiDetail.getIsJin());
//                                    datainfo.setMax(zsdingzhiDetail.getMax());
//                                    datainfo.setMin(zsdingzhiDetail.getMin());
//                                    datainfo.setIsBitian(zsdingzhiDetail.getIsBitian());
//                                    datainfo.setSysOrgCode(sys_org_code);
//                                    datainfo.setCreateBy(create_by);
//                                    datainfo.setCode(zsdingzhiDetail.getCode());
//                                    code8 = formalCategoryInfoMapper.add_testbodySize(datainfo);
//                                }
//                            }
//                        } else {//没删
//                            //根据编号查询正式的绣字部位有没有，如果有就执行修改，没有就执行添加
//                            BodySizeTestInfo zsdingzhiDetail = againEnabledMapper.query_zsbodysizeByCode(bodysizelist1.get(i).getCode(), formalcategory_id);
//                            if (zsdingzhiDetail != null) {
//                                //循环修改身体尺寸
//                                BodySizeTestInfo datainfo = new BodySizeTestInfo();
//                                datainfo.setBodySizename(bodysizelist1.get(i).getBodySizename());
//                                datainfo.setUnit(bodysizelist1.get(i).getUnit());
//                                datainfo.setModuleId(bodysizelist1.get(i).getModuleId());
//                                datainfo.setNumbers(bodysizelist1.get(i).getNumbers());
//                                datainfo.setIsJin(bodysizelist1.get(i).getIsJin());
//                                datainfo.setMax(bodysizelist1.get(i).getMax());
//                                datainfo.setMin(bodysizelist1.get(i).getMin());
//                                datainfo.setIsBitian(bodysizelist1.get(i).getIsBitian());
//                                datainfo.setSysOrgCode(sys_org_code);
//                                datainfo.setUpdateBy(create_by);
//                                datainfo.setId(zsdingzhiDetail.getId());
//                                code8 = againEnabledMapper.change_zsbodysizeById(datainfo);
//                            } else {
//                                //循环添加身体尺寸
//                                BodySizeTestInfo datainfo = new BodySizeTestInfo();
//                                datainfo.setBodySizename(bodysizelist1.get(i).getBodySizename());
//                                datainfo.setUnit(bodysizelist1.get(i).getUnit());
//                                datainfo.setModuleId(bodysizelist1.get(i).getModuleId());
//                                datainfo.setCategoryId(formalcategory_id);
//                                datainfo.setNumbers(bodysizelist1.get(i).getNumbers());
//                                datainfo.setIsJin(bodysizelist1.get(i).getIsJin());
//                                datainfo.setMax(bodysizelist1.get(i).getMax());
//                                datainfo.setMin(bodysizelist1.get(i).getMin());
//                                datainfo.setIsBitian(bodysizelist1.get(i).getIsBitian());
//                                datainfo.setSysOrgCode(sys_org_code);
//                                datainfo.setCreateBy(create_by);
//                                datainfo.setCode(bodysizelist1.get(i).getCode());
//                                code8 = formalCategoryInfoMapper.add_testbodySize(datainfo);
//                            }
//                        }
//                    }
                }
                if (fanxiulist.size() > 0) {
                    //先执行根据正式品类id删除全部
//                    againEnabledMapper.delete_zs_fanxiusizeByTopId(formalcategory_id);
                    for (int i = 0; i < fanxiulist.size(); i++) {
                        if (fanxiulist.get(i).getStatus() != 0) {//假删除
                            //根据编号删除正式的绣字部位
                            code9 = againEnabledMapper.delete_zsFanxiuByCodeplate(fanxiulist.get(i).getCode(), formalcategory_id);
                            System.out.println("删除成功==" + code66);
                            //根据编号查询正式的绣字部位有没有，如果有就执行修改，没有就执行添加
                            CategoryFanxiuTestInfo zsdingzhiDetail = againEnabledMapper.query_testFanxiuByCode(fanxiulist.get(i).getCode(), category_id);
                            if (zsdingzhiDetail != null) {
                                //循环添加返修
                                CategoryFanxiuTestInfo datainfo = new CategoryFanxiuTestInfo();
                                datainfo.setBodySizename(zsdingzhiDetail.getBodySizename());
                                datainfo.setUnit(zsdingzhiDetail.getUnit());
                                datainfo.setCode(zsdingzhiDetail.getCode());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setNumbers(zsdingzhiDetail.getNumbers());
                                datainfo.setMax(zsdingzhiDetail.getMax());
                                datainfo.setMin(zsdingzhiDetail.getMin());
                                datainfo.setRemark(zsdingzhiDetail.getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code9 = formalCategoryInfoMapper.add_testFanxiuSize(datainfo);
                            }
                        } else {//没删
                            //根据编号查询正式的绣字部位有没有，如果有就执行修改，没有就执行添加
                            CategoryFanxiuTestInfo zsdingzhiDetail = againEnabledMapper.query_zsFanxiuByCode(fanxiulist.get(i).getCode(), formalcategory_id);
                            if (zsdingzhiDetail != null) {
                                //循环修改返修
                                CategoryFanxiuTestInfo datainfo = new CategoryFanxiuTestInfo();
                                datainfo.setBodySizename(fanxiulist.get(i).getBodySizename());
                                datainfo.setUnit(fanxiulist.get(i).getUnit());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setNumbers(fanxiulist.get(i).getNumbers());
                                datainfo.setMax(fanxiulist.get(i).getMax());
                                datainfo.setMin(fanxiulist.get(i).getMin());
                                datainfo.setRemark(fanxiulist.get(i).getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setUpdateBy(create_by);
                                datainfo.setId(zsdingzhiDetail.getId());
                                code9 = againEnabledMapper.change_zsFanxiuById(datainfo);
                            } else {
                                //循环添加返修
                                CategoryFanxiuTestInfo datainfo = new CategoryFanxiuTestInfo();
                                datainfo.setBodySizename(fanxiulist.get(i).getBodySizename());
                                datainfo.setUnit(fanxiulist.get(i).getUnit());
                                datainfo.setCode(fanxiulist.get(i).getCode());
                                datainfo.setCategoryId(formalcategory_id);
                                datainfo.setNumbers(fanxiulist.get(i).getNumbers());
                                datainfo.setMax(fanxiulist.get(i).getMax());
                                datainfo.setMin(fanxiulist.get(i).getMin());
                                datainfo.setRemark(fanxiulist.get(i).getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code9 = formalCategoryInfoMapper.add_testFanxiuSize(datainfo);
                            }
                        }
                    }
                }
                /**
                 * 工艺模块
                 * */
                if(gongyilist.size()>0){
                    for (int i = 0;i<gongyilist.size();i++){
                        if(gongyilist.get(i).getStatus()==1){//假删除
                            //根据编号删除正式的定制项
                            code10 = againEnabledMapper.delete_zsgongyiByCode(gongyilist.get(i).getCategoryCode(),formalcategory_id);
                            System.out.println("删除成功=="+code10);
                        }else {//没删
                            //根据编号查询正式的定制项有没有，如果有就执行修改，没有就执行添加
                            MlccCategoryInfo zsdingzhiDetail = againEnabledMapper.query_zsgongyiDetailByCode(gongyilist.get(i).getCategoryCode(),formalcategory_id);
                            if(zsdingzhiDetail != null){
                                //执行修改
                                MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                                datainfo.setCategoryName(gongyilist.get(i).getCategoryName());
                                datainfo.setImg(gongyilist.get(i).getImg());
                                datainfo.setRemark(gongyilist.get(i).getRemark());
                                datainfo.setTopid(formalcategory_id);
                                datainfo.setCategorySex(gongyilist.get(i).getCategorySex());
                                datainfo.setNumbers(gongyilist.get(i).getNumbers());
                                datainfo.setStatus(0);
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setUpdateBy(create_by);
                                datainfo.setId(zsdingzhiDetail.getId());
                                code10 = againEnabledMapper.change_gongyiById(datainfo);
                            }else {
                                //执行添加
                                MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                                datainfo.setCategoryCode(gongyilist.get(i).getCategoryCode());
                                datainfo.setCategoryName(gongyilist.get(i).getCategoryName());
                                datainfo.setParentId(gongyilist.get(i).getParentId());
                                datainfo.setImg(gongyilist.get(i).getImg());
                                datainfo.setRemark(gongyilist.get(i).getRemark());
                                datainfo.setTopid(formalcategory_id);
                                datainfo.setIsType(4);
                                datainfo.setCategorySex(gongyilist.get(i).getCategorySex());
                                datainfo.setNumbers(gongyilist.get(i).getNumbers());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code10 = formalCategoryInfoMapper.add_category_pinglei2(datainfo);
                            }
                        }
                    }
                }
                /**
                 * 撞色
                 */
                if(zhuangselist.size()>0) {
                    for (int i = 0; i < zhuangselist.size(); i++) {
                        if(zhuangselist.get(i).getStatus()==1){
                            //根据编号和上级id执行删除
                            code7 = againEnabledMapper.delete_zszhuangseByCode(zhuangselist.get(i).getCode(),formalcategory_id);
                            System.out.println("删除撞色成功=="+code10);
                        }else {
                            ContrastcolorInfo zs_zhuangse = formalCategoryInfoMapper.queryZhuangseDetailByCode(zhuangselist.get(i).getCode(), formalcategory_id, 0, 0);
                            String praent_id = "", firstId = "";
                            SmalltemplateTestInfo ceshidingdatainfo = categoryInfoMapper.query_dingzhiBydingzhId(zhuangselist.get(i).getDingzhiId());
                            if (ceshidingdatainfo != null) {
                                //查询新增的定制项
                                List<SmalltemplateTestInfo> zsdingzhi_datalist = formalCategoryInfoMapper.query_dingzhiBycategoryId(formalcategory_id);
                                if (zsdingzhi_datalist.size() > 0) {
                                    for (int k = 0; k < zsdingzhi_datalist.size(); k++) {
                                        if (ceshidingdatainfo.getCode().equals(zsdingzhi_datalist.get(k).getCode())) {
                                            praent_id = zsdingzhi_datalist.get(k).getId().toString();
                                        }
                                    }
                                }
                            }
                            //根据类别id查询类别详情
                            MlccCategoryTestInfo leibiedatainfo1 = categoryInfoMapper.select_testcategoryDetail(zhuangselist.get(i).getCategoryId());
                            if (leibiedatainfo1 != null) {
                                MlccCategoryInfo zsleibie = formalCategoryInfoMapper.select_zscategoryDetailByother(leibiedatainfo1.getCategoryCode(), formalcategory_id, praent_id);
                                if (zsleibie != null) {
                                    firstId = zsleibie.getId().toString();
                                }
                            }
                            if (zs_zhuangse != null) {
                                //循环修改撞色
                                System.out.println("走修改3===" + praent_id + "===" + firstId);
                                ContrastcolorTestInfo datainfo = new ContrastcolorTestInfo();
                                datainfo.setCode(zhuangselist.get(i).getCode());
                                datainfo.setContrastColorName(zhuangselist.get(i).getContrastColorName());
                                datainfo.setCategoryId(firstId);
                                datainfo.setContrastColorImg(zhuangselist.get(i).getContrastColorImg());
                                datainfo.setDingzhiId(praent_id);
                                datainfo.setRemark(zhuangselist.get(i).getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setUpdateBy(create_by);
                                datainfo.setId(zs_zhuangse.getId());
                                code7 = formalCategoryInfoMapper.change_zhuangse(datainfo);
                            } else {
                                //循环添加撞色
                                System.out.println("走增加3===" + praent_id + "===" + firstId);
                                ContrastcolorTestInfo datainfo = new ContrastcolorTestInfo();
                                datainfo.setTopId(formalcategory_id);
                                datainfo.setCode(zhuangselist.get(i).getCode());
                                datainfo.setContrastColorName(zhuangselist.get(i).getContrastColorName());
                                datainfo.setCategoryId(firstId);
                                datainfo.setContrastColorImg(zhuangselist.get(i).getContrastColorImg());
                                datainfo.setDingzhiId(praent_id);
                                datainfo.setRemark(zhuangselist.get(i).getRemark());
                                datainfo.setSysOrgCode(sys_org_code);
                                datainfo.setCreateBy(create_by);
                                code7 = formalCategoryInfoMapper.add_zhuangse(datainfo);
                            }
                        }
                    }
                }

                if(fuliaolist.size()>0){
                    for (int i=0;i<fuliaolist.size();i++){
                        //循环添加辅料项--正式
                        CategoryMaterialInfo datainfo = new CategoryMaterialInfo();
                        datainfo.setOtherId(fuliaolist.get(i).getOtherId());
                        datainfo.setCategoryId(formalcategory_id);
                        datainfo.setIsLibu(fuliaolist.get(i).getIsLibu());
                        datainfo.setRemark(fuliaolist.get(i).getRemark());
                        datainfo.setSysOrgCode(sys_org_code);
                        datainfo.setCreateBy(create_by);
                        code666 = formalPlateInfoMapper.add_plate_libu(datainfo);
                    }
                }
                if(standcodelist.size()>0){
                    for (int i=0;i<standcodelist.size();i++){
                        //循环添加标准码项--正式
                        StandardCodeInfo datainfo = new StandardCodeInfo();
                        String codefanxiu = UUID.randomUUID().toString().substring(0,12);
                        //8位随机数
                        int random=new Random().nextInt(100000)+1;//为变量赋随机值1-99999999;
                        String standcodeId = codefanxiu+random+i;
                        datainfo.setId(standcodeId);
                        datainfo.setCategoryId(formalcategory_id);
                        datainfo.setStandardName(standcodelist.get(i).getStandardName());
                        datainfo.setCode(standcodelist.get(i).getCode());
                        datainfo.setNumbers(standcodelist.get(i).getNumbers());
                        datainfo.setRemark(standcodelist.get(i).getRemark());
                        datainfo.setSysOrgCode(sys_org_code);
                        datainfo.setCreateBy(create_by);
                        code666 = testPlateInfoMapper.add_StandardCode_zhengshi(datainfo);
                    }
                }

                Long startTs2 = System.currentTimeMillis(); // 当前时间戳
                System.out.println("输出时间========"+(startTs2-startTs1));
                System.out.println("各个code=="+code2+"="+code3+"="+code4+"="+code5+"="+code6+"="+code66+"="+code7+"="+code8+"="+code9+"="+code10+"==67=="+code67);
                if(code2>0 || code3>0 || code4>0 || code5>0 || code6>0 || code66>0 || code7>0 || code8>0 || code9>0 || code10>0 || code666>0){
                    //测试区
                    formalCategoryInfoMapper.add_qiyong_record(category_id,"1","0",zhengshi_categoryName+" 【再次】 启用成为正式版号",create_by,sys_org_code);
                    //正式插入记录
                    formalCategoryInfoMapper.add_qiyong_record(formalcategory_id,"1","0","已由草稿件"+zhengshi_categoryName+" 【再次】 启用成为正式版号",create_by,sys_org_code);
                    return 10;
                }else {
                    return 1;
                }
            }
        }else {//第一次启用
            //赋值测试类别id
            testcategoryDetail.setTestcategoryId(testcategoryDetail.getId().toString());
            int code1 = formalCategoryInfoMapper.add_category_pinglei2(testcategoryDetail);
            int code2 = 0,code3=0,code4=0,code5=0,code6=0,code7=0,code8=0,code9=0,code10=0,code66=0,code666=0;
            if(code1>0){
                //根据品类id查询定制项
                List<SmalltemplateTestInfo> dingzhilist = categoryInfoMapper.query_dingzhiBycategoryId(category_id);
                //根据品类id查询定制项下的参数
                List<MlccCategoryTestInfo> canshulist = formalCategoryInfoMapper.query_AllcanshuBypingleiId(category_id);
                //根据品类id查询互斥项
                List<MutexTestInfo> huchilist = formalCategoryInfoMapper.query_AllhuchiBypingleiId(category_id);
                //根据品类id查询绣字部位
                List<CategoryLocationTestInfo> xuzilist1 = formalCategoryInfoMapper.query_Allxiuzi1BypingleiId(category_id);
                //根据品类id查询绣字颜色
                List<EmbroideredColorTestInfo> xuzilist2 = formalCategoryInfoMapper.query_AllxiuziColorBypingleiId(category_id);
                //根据品类id查询绣字图片
                List<EmbroideredFontTestInfo> xuzilist3 = formalCategoryInfoMapper.query_AllxiuziFontBypingleiId(category_id);
                //根据品类id查询撞色
                List<ContrastcolorTestInfo> zhuangselist = formalCategoryInfoMapper.query_AllzhuangseBypingleiId(category_id);
                //根据品类id查询净体尺寸
                List<BodySizeTestInfo> bodysizelist1 = formalCategoryInfoMapper.query_AlljingtiBodysizeBypingleiId(category_id);
                //根据品类id查询返修
                List<CategoryFanxiuTestInfo> fanxiulist = formalCategoryInfoMapper.query_AllFanxiuBypingleiId(category_id);
                //根据品类id查询工艺类型
                List<MlccCategoryTestInfo> gongyilist = formalCategoryInfoMapper.query_AllGongyiBypingleiId(category_id);
                //根据品类id查询系统加急---cesih
                List<AddSystemPriceInfo> syspricelist = formalCategoryInfoMapper.query_AllsyspriceBypingleiId(category_id,1);
                List<AddSystemPriceInfo> syspricelist2 = formalCategoryInfoMapper.query_AllsyspriceBypingleiId(category_id,0);
                //根据品类id查询所有绣字高度-测试
                List<EmbroidedHeightInfo> xiuziHeightlist = formalCategoryInfoMapper.query_AllxiuziHeightBypingleiId(category_id);

                //根据版号id查询测试的辅料
                List<CategoryMaterialInfo> fuliaolist = formalPlateInfoMapper.query_AllfuliaoBypingleiId(category_id);
                //根据版号id查询测试的标准码
                List<StandardCodeInfo> standcodelist = testPlateInfoMapper.query_standardCodelist(category_id,2);

                MlccCategoryInfo pingleiDetail = againEnabledMapper.select_zscategoryDetail(testcategoryDetail.getCategoryCode());
                if(pingleiDetail!=null){
                    String zspingleiId = pingleiDetail.getId().toString();//正式品类id
                    zhengshi_categoryId = pingleiDetail.getId().toString();//正式品类id
                    zhengshi_categoryName = pingleiDetail.getCategoryName();
                    if(dingzhilist.size()>0){
                        for (int i=0;i<dingzhilist.size();i++){
                            //循环添加定制项
                            SmalltemplateTestInfo datainfo = new SmalltemplateTestInfo();
                            datainfo.setModuleId(dingzhilist.get(i).getModuleId());
                            datainfo.setCategoryId(zspingleiId);
                            datainfo.setCode(dingzhilist.get(i).getCode());
                            datainfo.setParameter(dingzhilist.get(i).getParameter());
                            datainfo.setImgs(dingzhilist.get(i).getImgs());
                            datainfo.setNumbers(dingzhilist.get(i).getNumbers());
                            datainfo.setIstype(dingzhilist.get(i).getIstype());
                            datainfo.setRemark(dingzhilist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code2 = formalCategoryInfoMapper.add_dingzhi(datainfo);
                        }
                    }
                    if(canshulist.size()>0){
                        for (int i=0;i<canshulist.size();i++){
                            String praent_id = "";
                            SmalltemplateTestInfo ceshidingdatainfo = categoryInfoMapper.query_dingzhiBydingzhId(canshulist.get(i).getParentId());
                            if(ceshidingdatainfo!=null){
                                //查询新增的定制项
                                List<SmalltemplateTestInfo> zsdingzhi_datalist = formalCategoryInfoMapper.query_dingzhiBycategoryId(zspingleiId);
                                if(zsdingzhi_datalist.size()>0){
                                    for (int k=0;k<zsdingzhi_datalist.size();k++){
                                        if(ceshidingdatainfo.getCode().equals(zsdingzhi_datalist.get(k).getCode())){
                                            praent_id = zsdingzhi_datalist.get(k).getId().toString();
                                        }
                                    }
                                }
                            }
                            //循环添加定制项下的参数
                            MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                            datainfo.setCategoryName(canshulist.get(i).getCategoryName());
                            datainfo.setCategoryCode(canshulist.get(i).getCategoryCode());
                            datainfo.setParentId(praent_id);//正式的上级id
                            datainfo.setImg(canshulist.get(i).getImg());
                            datainfo.setTopid(zspingleiId);
                            datainfo.setNumbers(canshulist.get(i).getNumbers());
                            datainfo.setIsType(canshulist.get(i).getIsType());
                            datainfo.setCost(canshulist.get(i).getCost());
                            datainfo.setTeamPrice2(canshulist.get(i).getTeamPrice2());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            datainfo.setStatus(0);
                            code3 = formalCategoryInfoMapper.add_dingzhi_canshu(datainfo);
                        }
                    }

                    if(huchilist.size()>0){
                        for (int i=0;i<huchilist.size();i++){
                            //查询新增的定制项
                            String dingzhi1="",dingzhi2="";
                            String firstId = "",secoundId="";
                            List<SmalltemplateTestInfo> zsdingzhi_datalist = formalCategoryInfoMapper.query_dingzhiBycategoryId(zspingleiId);
                            SmalltemplateTestInfo ceshidingdatainfo1 = categoryInfoMapper.query_dingzhiBydingzhId(huchilist.get(i).getDingzhi1());
                            SmalltemplateTestInfo ceshidingdatainfo2 = categoryInfoMapper.query_dingzhiBydingzhId(huchilist.get(i).getDingzhi2());
                            if(ceshidingdatainfo1!=null){
                                if(zsdingzhi_datalist.size()>0){
                                    for (int k=0;k<zsdingzhi_datalist.size();k++){
                                        if(ceshidingdatainfo1.getCode().equals(zsdingzhi_datalist.get(k).getCode())){
                                            dingzhi1 = zsdingzhi_datalist.get(k).getId().toString();
                                            break;
                                        }
                                    }
                                }
                            }
                            if(ceshidingdatainfo2!=null){
                                if(zsdingzhi_datalist.size()>0){
                                    for (int k=0;k<zsdingzhi_datalist.size();k++){
                                        if(ceshidingdatainfo2.getCode().equals(zsdingzhi_datalist.get(k).getCode())){
                                            dingzhi2 = zsdingzhi_datalist.get(k).getId().toString();
                                            break;
                                        }
                                    }
                                }
                            }
                            //根据类别id查询类别详情
                            MlccCategoryTestInfo leibiedatainfo1 = categoryInfoMapper.select_testcategoryDetail(huchilist.get(i).getCategoryId());
                            if(leibiedatainfo1!=null){
                                MlccCategoryInfo zsleibie = formalCategoryInfoMapper.select_zscategoryDetailByother(leibiedatainfo1.getCategoryCode(),zspingleiId,dingzhi1);
                                if(zsleibie!=null){
                                    firstId = zsleibie.getId().toString();
                                }
                            }
                            String canshuids[] = huchilist.get(i).getCategoryOther().split(",");
                            String strbody="";
                            for (String s:canshuids){
                                //根据类别id查询类别详情
                                MlccCategoryTestInfo leibiedatainfo2 = categoryInfoMapper.select_testcategoryDetail(s);
                                if(leibiedatainfo2!=null){
                                    MlccCategoryInfo zsleibie = formalCategoryInfoMapper.select_zscategoryDetailByother(leibiedatainfo2.getCategoryCode(),zspingleiId,dingzhi2);
                                    if(zsleibie!=null){
                                        strbody += zsleibie.getId().toString()+",";
                                    }
                                }
                            }
                            if(strbody==null || "".equals(strbody)){
                                secoundId = "";
                            }else {
                                secoundId = strbody.substring(0,strbody.length()-1);
                            }
                            //循环添加互斥
                            MutexTestInfo datainfo = new MutexTestInfo();
                            datainfo.setMutexName(huchilist.get(i).getMutexName());
                            datainfo.setTopId(zspingleiId);
                            datainfo.setCategoryId(firstId);
                            datainfo.setCategoryOther(secoundId);
                            datainfo.setMutexReason(huchilist.get(i).getMutexReason());
                            datainfo.setStatus(huchilist.get(i).getStatus());
                            datainfo.setCode(huchilist.get(i).getCode());
                            datainfo.setDingzhi1(dingzhi1);
                            datainfo.setDingzhi2(dingzhi2);
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code4 = formalCategoryInfoMapper.add_huchi(datainfo);
                        }
                    }
                    if(xuzilist1.size()>0){
                        for (int i=0;i<xuzilist1.size();i++){
                            //循环添加绣字部位
                            CategoryLocationTestInfo datainfo = new CategoryLocationTestInfo();
                            datainfo.setCode(xuzilist1.get(i).getCode());
                            datainfo.setXiuziLocaltion(xuzilist1.get(i).getXiuziLocaltion());
                            datainfo.setCategoryId(zspingleiId);
                            datainfo.setRemark(xuzilist1.get(i).getRemark());
                            datainfo.setNumbers(xuzilist1.get(i).getNumbers());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code5 = formalCategoryInfoMapper.add_xiuzi_location(datainfo);
                        }
                    }
                    if(xuzilist2.size()>0){
                        for (int i=0;i<xuzilist2.size();i++){
                            //循环添加绣字颜色
                            EmbroideredColorTestInfo datainfo = new EmbroideredColorTestInfo();
                            datainfo.setCode(xuzilist2.get(i).getCode());
                            datainfo.setColorName(xuzilist2.get(i).getColorName());
                            datainfo.setCategoryId(zspingleiId);
                            datainfo.setColorImg(xuzilist2.get(i).getColorImg());
                            datainfo.setRemark(xuzilist2.get(i).getRemark());
                            datainfo.setNumbers(xuzilist2.get(i).getNumbers());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code6 = formalCategoryInfoMapper.add_xiuzi_color(datainfo);
                        }
                    }
                    if(xuzilist3.size()>0){
                        for (int i=0;i<xuzilist3.size();i++){
                            //循环添加绣字字体
                            EmbroideredFontTestInfo datainfo = new EmbroideredFontTestInfo();
                            datainfo.setCode(xuzilist3.get(i).getCode());
                            datainfo.setEmbroideredName(xuzilist3.get(i).getEmbroideredName());
                            datainfo.setCategoryId(zspingleiId);
                            datainfo.setEmbroideredImage(xuzilist3.get(i).getEmbroideredImage());
                            datainfo.setRemark(xuzilist3.get(i).getRemark());
                            datainfo.setNumbers(xuzilist3.get(i).getNumbers());
                            datainfo.setIsZitiImg(xuzilist3.get(i).getIsZitiImg());
                            datainfo.setXiuziSize(xuzilist3.get(i).getXiuziSize());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code66 = formalCategoryInfoMapper.add_xiuzi_fontImg(datainfo);
                        }
                    }
                    if(xiuziHeightlist.size()>0){
                        for (int i=0;i<xiuziHeightlist.size();i++){
                            //循环添加绣字高度
                            EmbroidedHeightInfo datainfo = new EmbroidedHeightInfo();
                            datainfo.setEmbroideredHeight(xiuziHeightlist.get(i).getEmbroideredHeight());
                            datainfo.setHeightCode(xiuziHeightlist.get(i).getHeightCode());
                            datainfo.setCategoryId(zspingleiId);
                            datainfo.setRemark(xiuziHeightlist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code66 = testPlateInfoMapper.add_xiuzi_height(datainfo);
                        }
                    }
                    if(zhuangselist.size()>0){
                        for (int i=0;i<zhuangselist.size();i++){
                            String praent_id = "",firstId="";
                            SmalltemplateTestInfo ceshidingdatainfo = categoryInfoMapper.query_dingzhiBydingzhId(zhuangselist.get(i).getDingzhiId());
                            if(ceshidingdatainfo!=null){
                                //查询新增的定制项
                                List<SmalltemplateTestInfo> zsdingzhi_datalist = formalCategoryInfoMapper.query_dingzhiBycategoryId(zspingleiId);
                                if(zsdingzhi_datalist.size()>0){
                                    for (int k=0;k<zsdingzhi_datalist.size();k++){
                                        if(ceshidingdatainfo.getCode().equals(zsdingzhi_datalist.get(k).getCode())){
                                            praent_id = zsdingzhi_datalist.get(k).getId().toString();
                                        }
                                    }
                                }
                            }
                            //根据类别id查询类别详情
                            MlccCategoryTestInfo leibiedatainfo1 = categoryInfoMapper.select_testcategoryDetail(zhuangselist.get(i).getCategoryId());
                            if(leibiedatainfo1!=null){
                                MlccCategoryInfo zsleibie = formalCategoryInfoMapper.select_zscategoryDetailByother(leibiedatainfo1.getCategoryCode(),zspingleiId,praent_id);
                                if(zsleibie!=null){
                                    firstId = zsleibie.getId().toString();
                                }
                            }
                            //循环添加撞色
                            ContrastcolorTestInfo datainfo = new ContrastcolorTestInfo();
                            datainfo.setTopId(zspingleiId);
                            datainfo.setCode(zhuangselist.get(i).getCode());
                            datainfo.setContrastColorName(zhuangselist.get(i).getContrastColorName());
                            datainfo.setCategoryId(firstId);
                            datainfo.setContrastColorImg(zhuangselist.get(i).getContrastColorImg());
                            datainfo.setDingzhiId(praent_id);
                            datainfo.setRemark(zhuangselist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code7 = formalCategoryInfoMapper.add_zhuangse(datainfo);
                        }
                    }
                    if(bodysizelist1.size()>0){
                        for (int i=0;i<bodysizelist1.size();i++){
                            //循环添加身体尺寸
                            BodySizeTestInfo datainfo = new BodySizeTestInfo();
                            datainfo.setBodySizename(bodysizelist1.get(i).getBodySizename());
                            datainfo.setUnit(bodysizelist1.get(i).getUnit());
                            datainfo.setModuleId(bodysizelist1.get(i).getModuleId());
                            datainfo.setCategoryId(zspingleiId);
                            datainfo.setNumbers(bodysizelist1.get(i).getNumbers());
                            datainfo.setIsJin(bodysizelist1.get(i).getIsJin());
                            datainfo.setMax(bodysizelist1.get(i).getMax());
                            datainfo.setMin(bodysizelist1.get(i).getMin());
                            datainfo.setIsBitian(bodysizelist1.get(i).getIsBitian());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            datainfo.setCode(bodysizelist1.get(i).getCode());
                            code8 = formalCategoryInfoMapper.add_testbodySize(datainfo);
                        }
                    }
                    if(fanxiulist.size()>0){
                        for (int i=0;i<fanxiulist.size();i++){
                            //循环添加返修
                            CategoryFanxiuTestInfo datainfo = new CategoryFanxiuTestInfo();
                            datainfo.setBodySizename(fanxiulist.get(i).getBodySizename());
                            datainfo.setUnit(fanxiulist.get(i).getUnit());
                            datainfo.setCategoryId(zspingleiId);
                            datainfo.setNumbers(fanxiulist.get(i).getNumbers());
                            datainfo.setMax(fanxiulist.get(i).getMax());
                            datainfo.setMin(fanxiulist.get(i).getMin());
                            datainfo.setRemark(fanxiulist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            datainfo.setCode(fanxiulist.get(i).getCode());
                            code9 = formalCategoryInfoMapper.add_testFanxiuSize(datainfo);
                        }
                    }
//                    if(syspricelist.size()>0){
//                        for (int i=0;i<syspricelist.size();i++){
//                            //循环添加系统加急--上级
//                            AddSystemPriceInfo datainfo = new AddSystemPriceInfo();
//                            datainfo.setPremiumItem(syspricelist.get(i).getPremiumItem());
//                            datainfo.setPremiumCode(syspricelist.get(i).getPremiumCode());
//                            datainfo.setCategoryId(zspingleiId);
//                            datainfo.setType(syspricelist.get(i).getType());
//                            datainfo.setRemark(syspricelist.get(i).getRemark());
//                            datainfo.setSysOrgCode(sys_org_code);
//                            datainfo.setCreateBy(create_by);
//                            datainfo.setPartentId("0");
//                            datainfo.setIsTop(1);
//                            datainfo.setNumbers(syspricelist.get(i).getNumbers());
//                            code11 = formalCategoryInfoMapper.add_fomal_syspriceinfo(datainfo);
//                        }
//                    }
//
//                    if(syspricelist2.size()>0){
//                        for (int i=0;i<syspricelist2.size();i++){
//                            //根据编码查询系统加急项
//                            String praent_id = "";
//                            AddSystemPriceInfo ceshidingdatainfo = categoryInfoMapper.query_addsyspriceDetail(syspricelist2.get(i).getPartentId());
//                            if(ceshidingdatainfo!=null){
//                                //查询新增的上级加急项
//                                List<AddSystemPriceInfo> zsdingzhi_datalist = testPlateInfoMapper.query_AllsyspriceBypingleiId(zspingleiId,1);
//                                if(zsdingzhi_datalist.size()>0){
//                                    for (int k=0;k<zsdingzhi_datalist.size();k++){
//                                        if(ceshidingdatainfo.getPremiumCode().equals(zsdingzhi_datalist.get(k).getPremiumCode())){
//                                            praent_id = zsdingzhi_datalist.get(k).getId().toString();
//                                            break;
//                                        }
//                                    }
//                                }
//                            }
//                            //循环添加系统加急--下级
//                            AddSystemPriceInfo datainfo = new AddSystemPriceInfo();
//                            datainfo.setPremiumItem(syspricelist2.get(i).getPremiumItem());
//                            datainfo.setPremiumCode(syspricelist2.get(i).getPremiumCode());
//                            datainfo.setCategoryId(zspingleiId);
//                            datainfo.setType(syspricelist2.get(i).getType());
//                            datainfo.setRemark(syspricelist2.get(i).getRemark());
//                            datainfo.setSysOrgCode(sys_org_code);
//                            datainfo.setCreateBy(create_by);
//                            datainfo.setPartentId(praent_id);//上级
//                            datainfo.setIsTop(0);
//                            datainfo.setNumbers(syspricelist2.get(i).getNumbers());
//                            code11 = formalCategoryInfoMapper.add_fomal_syspriceinfo(datainfo);
//                        }
//                    }
                    if(gongyilist.size()>0){
                        for (int i=0;i<gongyilist.size();i++){
                            //循环添加工艺
                            MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                            datainfo.setCategoryCode(gongyilist.get(i).getCategoryCode());
                            datainfo.setCategoryName(gongyilist.get(i).getCategoryName());
                            datainfo.setParentId(gongyilist.get(i).getParentId());
                            datainfo.setImg(gongyilist.get(i).getImg());
                            datainfo.setRemark(gongyilist.get(i).getRemark());
                            datainfo.setTopid(zspingleiId);
                            datainfo.setIsType(4);
                            datainfo.setCategorySex(gongyilist.get(i).getCategorySex());
                            datainfo.setNumbers(gongyilist.get(i).getNumbers());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code10 = formalCategoryInfoMapper.add_category_pinglei2(datainfo);
                        }
                    }
                    if(fuliaolist.size()>0){
                        for (int i=0;i<fuliaolist.size();i++){
                            //循环添加辅料项--正式
                            CategoryMaterialInfo datainfo = new CategoryMaterialInfo();
                            datainfo.setOtherId(fuliaolist.get(i).getOtherId());
                            datainfo.setCategoryId(zspingleiId);
                            datainfo.setIsLibu(fuliaolist.get(i).getIsLibu());
                            datainfo.setRemark(fuliaolist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code666 = formalPlateInfoMapper.add_plate_libu(datainfo);
                        }
                    }
                    if(standcodelist.size()>0){
                        for (int i=0;i<standcodelist.size();i++){
                            //循环添加标准码项--正式
                            StandardCodeInfo datainfo = new StandardCodeInfo();
                            String codefanxiu = UUID.randomUUID().toString().substring(0,12);
                            //8位随机数
                            int random=new Random().nextInt(100000)+1;//为变量赋随机值1-99999999;
                            String standcodeId = codefanxiu+random+i;
                            datainfo.setId(standcodeId);
                            datainfo.setCategoryId(zspingleiId);
                            datainfo.setStandardName(standcodelist.get(i).getStandardName());
                            datainfo.setCode(standcodelist.get(i).getCode());
                            datainfo.setNumbers(standcodelist.get(i).getNumbers());
                            datainfo.setRemark(standcodelist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code666 = testPlateInfoMapper.add_StandardCode_zhengshi(datainfo);
                        }
                    }
                }
                System.out.println("各个code=="+code2+"="+code3+"="+code4+"="+code5+"="+code6+"="+code66+"="+code7+"="+code8+"="+code9+"="+code10);
                if(code2>0 || code3>0 || code4>0 || code5>0 || code6>0 || code66>0 || code666>0 || code7>0 || code8>0 || code9>0 || code10>0){
                    //测试区
                    formalCategoryInfoMapper.add_qiyong_record(category_id,"1","0",zhengshi_categoryName+"正式启用成为正式版号",create_by,sys_org_code);
                    //正式插入记录
                    formalCategoryInfoMapper.add_qiyong_record(zhengshi_categoryId,"1","0","已由草稿件"+zhengshi_categoryName+"正式启用成为正式版号",create_by,sys_org_code);
                    return 0;
                }else {
                    return 1;
                }
            }else {
                return 500;
            }
        }
    }

    /**
     * 版号同步品类参数
     * @param category_id 正式品类ID
     * @param plate_id 测试版号ID
     */
    @Override
    public int synchronization_parameter(String category_id, String plate_id) {
        Long start_time = System.currentTimeMillis();
        //获取登录用户信息
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String sys_org_code = sysUser.getOrgCode();
        String create_by = sysUser.getUsername();
        /**查询正式品类下的参数*/
        //根据品类id查询定制项
        List<SmalltemplateTestInfo> dingzhilist = againEnabledMapper.query_zs_dingzhiBytopId(category_id);
        //根据品类id查询定制项下的参数
        List<MlccCategoryTestInfo> canshulist = againEnabledMapper.query_zs_dingzhi_canshuBytopId(category_id);
        //根据品类id查询互斥项
        List<MutexTestInfo> huchilist = againEnabledMapper.query_zs_mutextBytopId(category_id);
        //根据品类id查询绣字部位
        List<CategoryLocationTestInfo> xuzilist1 = againEnabledMapper.query_zs_LocationBytopId(category_id);
        //根据品类id查询绣字颜色
        List<EmbroideredColorTestInfo> xuzilist2 = againEnabledMapper.query_zs_EmbroideredColorBytopId(category_id);
        //根据品类id查询绣字图片
        List<EmbroideredFontTestInfo> xuzilist3 = againEnabledMapper.query_zs_EmbroideredFontBytopId(category_id);
        //根据品类id查询撞色
        List<ContrastcolorTestInfo> zhuangselist = againEnabledMapper.query_zs_ContrastcolorBytopId(category_id);
        //根据品类id查询净体尺寸
        List<BodySizeTestInfo> bodysizelist1 = againEnabledMapper.query_zs_BodySizeBytopId(category_id);
        //根据品类id查询返修
        List<CategoryFanxiuTestInfo> fanxiulist = againEnabledMapper.query_zs_CategoryFanxiuBytopId(category_id);
        //根据品类id查询工艺类型
        List<MlccCategoryTestInfo> gongyilist = againEnabledMapper.query_zs_MlccCategoryBytopId(category_id);

        //根据品类id查询净体尺寸2
        List<BodySizeTestInfo> bodysizelist2 = testPlateInfoMapper.query_AlljingtiBodysizeBypingleiId(category_id);

//        /**根据版号ID查询测试区的数据*/
//        //根据品类id查询定制项
//        List<SmalltemplateTestInfo> test_dingzhilist = againEnabledMapper.query_dingzhiBytopId(plate_id);
//        //根据品类id查询定制项下的参数
//        List<MlccCategoryTestInfo> test_canshulist = againEnabledMapper.query_dingzhi_canshuBytopId(plate_id);
//        //根据品类id查询互斥项
//        List<MutexTestInfo> test_huchilist = againEnabledMapper.query_mutextBytopId(plate_id);
//        //根据品类id查询绣字部位
//        List<CategoryLocationTestInfo> test_xuzilist1 = againEnabledMapper.query_LocationBytopId(plate_id);
//        //根据品类id查询绣字颜色
//        List<EmbroideredColorTestInfo> test_xuzilist2 = againEnabledMapper.query_EmbroideredColorBytopId(plate_id);
//        //根据品类id查询绣字图片
//        List<EmbroideredFontTestInfo> test_xuzilist3 = againEnabledMapper.query_EmbroideredFontBytopId(plate_id);
//        //根据品类id查询撞色
//        List<ContrastcolorTestInfo> test_zhuangselist = againEnabledMapper.query_ContrastcolorBytopId(plate_id);
//        //根据品类id查询净体尺寸
//        List<BodySizeTestInfo> test_bodysizelist1 = againEnabledMapper.query_BodySizeBytopId(plate_id);
//        //根据品类id查询返修
//        List<CategoryFanxiuTestInfo> test_fanxiulist = againEnabledMapper.query_CategoryFanxiuBytopId(plate_id);
//        //根据品类id查询工艺类型
//        List<MlccCategoryTestInfo> test_gongyilist = againEnabledMapper.query_MlccCategoryBytopId(plate_id);

        int code1=0,code2=0,code3=0,code4=0,code5=0,code6=0,code7=0,code8=0,code9=0,code10=0;
        /**
         * 工艺模块
         * */
        if(gongyilist.size()>0){
            for (int i = 0;i<gongyilist.size();i++){
                System.out.println("装提示=="+gongyilist.get(i).getStatus()+"==="+plate_id);
                if(gongyilist.get(i).getStatus() != 0){
                    //执行删除测试的数据-真删除
                    code10 = testPlateInfoMapper.delete_real_gongyi(plate_id,gongyilist.get(i).getCategoryCode());
                    System.out.println("删除工艺类型=="+gongyilist.get(i).getCategoryCode()+"==="+plate_id+"==="+code10);
                    //根据品类id和编号查询当前没有删除的数据--仅仅只有一个
                    MlccCategoryTestInfo zs_datadetail = againEnabledMapper.query_gongyitailByCode(gongyilist.get(i).getCategoryCode(),category_id,2);
                    if(zs_datadetail!=null){
                        MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                        datainfo.setCategoryCode(zs_datadetail.getCategoryCode());
                        datainfo.setCategoryName(zs_datadetail.getCategoryName());
                        datainfo.setParentId("4");
                        datainfo.setImg(zs_datadetail.getImg());
                        datainfo.setRemark(zs_datadetail.getRemark());
                        datainfo.setTopid(plate_id);
                        datainfo.setIsType(4);
                        datainfo.setCategorySex(zs_datadetail.getCategorySex());
                        datainfo.setNumbers(zs_datadetail.getNumbers());
                        datainfo.setSysOrgCode(sys_org_code);
                        datainfo.setCreateBy(create_by);
                        datainfo.setStatus(0);
                        code10 = categoryInfoMapper.add_category_pinglei(datainfo);
                    }
                }else {
                    MlccCategoryTestInfo datadetail = againEnabledMapper.query_gongyitailByCode(gongyilist.get(i).getCategoryCode(),plate_id,1);
                    if(datadetail != null){
                        System.out.println("修改工艺类型=="+datadetail.getId()+"==="+plate_id+"==="+gongyilist.get(i).getCategoryName());
                        //执行修改
                        MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                        datainfo.setCategoryName(gongyilist.get(i).getCategoryName());
                        datainfo.setImg(gongyilist.get(i).getImg());
                        datainfo.setRemark(gongyilist.get(i).getRemark());
                        datainfo.setIsType(4);
                        datainfo.setTopid(plate_id);
                        datainfo.setCategorySex(gongyilist.get(i).getCategorySex());
                        datainfo.setNumbers(gongyilist.get(i).getNumbers());
                        datainfo.setSysOrgCode(sys_org_code);
                        datainfo.setUpdateBy(create_by);
                        datainfo.setId(datadetail.getId());
                        code10 = categoryInfoMapper.update_category_pingleiName(datainfo);
                    }else {
                        System.out.println("增加工艺类型=="+gongyilist.get(i).getCategoryCode()+"==="+plate_id+"==="+gongyilist.get(i).getCategoryName());
                        MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                        datainfo.setCategoryCode(gongyilist.get(i).getCategoryCode());
                        datainfo.setCategoryName(gongyilist.get(i).getCategoryName());
                        datainfo.setParentId("4");
                        datainfo.setImg(gongyilist.get(i).getImg());
                        datainfo.setRemark(gongyilist.get(i).getRemark());
                        datainfo.setTopid(plate_id);
                        datainfo.setIsType(4);
                        datainfo.setCategorySex(gongyilist.get(i).getCategorySex());
                        datainfo.setNumbers(gongyilist.get(i).getNumbers());
                        datainfo.setSysOrgCode(sys_org_code);
                        datainfo.setCreateBy(create_by);
                        datainfo.setStatus(0);
                        code10 = categoryInfoMapper.add_category_pinglei(datainfo);
                    }
                }
            }
        }

        /**
         * 绣字模块
         * */
        if(xuzilist1.size()>0){
            System.out.println("绣字部位几个=="+xuzilist1.size());
                for (int i = 0;i<xuzilist1.size();i++){
                    if(xuzilist1.get(i).getStatus() != 0){
                        //执行删除测试的数据-真删除
                        code5 = testPlateInfoMapper.delete_real_xiuzi_location(plate_id,xuzilist1.get(i).getCode());
                        System.out.println("删除绣字部位=="+xuzilist1.get(i).getCode()+"==="+plate_id+"==="+code5);
                        //根据品类id和编号查询当前没有删除的数据--仅仅只有一个
                        CategoryLocationTestInfo zs_datadetail = againEnabledMapper.query_xiuzibuweietailByCode(xuzilist1.get(i).getCode(),category_id,2);
                        if(zs_datadetail!=null){
                            //执行添加
                            CategoryLocationTestInfo datainfo = new CategoryLocationTestInfo();
                            datainfo.setCode(zs_datadetail.getCode());
                            datainfo.setXiuziLocaltion(zs_datadetail.getXiuziLocaltion());
                            datainfo.setCategoryId(plate_id);
                            datainfo.setRemark(zs_datadetail.getRemark());
                            datainfo.setNumbers(zs_datadetail.getNumbers());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            datainfo.setStatus(0);
                            code5 = categoryInfoMapper.add_xiuzi_location(datainfo);
                        }

                    }else {
                        //根据编号和上级id查询绣字部位
                        CategoryLocationTestInfo xiuzi_location = againEnabledMapper.query_xiuzibuweietailByCode(xuzilist1.get(i).getCode(),plate_id,1);
                        if(xiuzi_location!=null){
                            System.out.println("修改绣字部位=="+xuzilist1.get(i).getCode()+"==="+plate_id+"==="+xiuzi_location.getId());
                            //执行修改
                            CategoryLocationTestInfo datainfo = new CategoryLocationTestInfo();
                            datainfo.setCode(xuzilist1.get(i).getCode());
                            datainfo.setXiuziLocaltion(xuzilist1.get(i).getXiuziLocaltion());
                            datainfo.setRemark(xuzilist1.get(i).getRemark());
                            datainfo.setNumbers(xuzilist1.get(i).getNumbers());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setUpdateBy(create_by);
                            datainfo.setId(xiuzi_location.getId());
                            code5 = categoryInfoMapper.update_xiuzi_location(datainfo);
                        }else {
                            System.out.println("增加绣字部位=="+xuzilist1.get(i).getCode()+"==="+plate_id);
                            //执行添加
                            CategoryLocationTestInfo datainfo = new CategoryLocationTestInfo();
                            datainfo.setCode(xuzilist1.get(i).getCode());
                            datainfo.setXiuziLocaltion(xuzilist1.get(i).getXiuziLocaltion());
                            datainfo.setCategoryId(plate_id);
                            datainfo.setRemark(xuzilist1.get(i).getRemark());
                            datainfo.setNumbers(xuzilist1.get(i).getNumbers());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            datainfo.setStatus(0);
                            code5 = categoryInfoMapper.add_xiuzi_location(datainfo);
                        }
                    }
                }
        }
        if(xuzilist2.size()>0){
                for (int i = 0;i<xuzilist2.size();i++){
                    if(xuzilist2.get(i).getStatus() != 0){
                        //执行删除测试的数据-真删除
                        code6 = testPlateInfoMapper.delete_real_xiuzi_color(plate_id,xuzilist2.get(i).getCode());
                        System.out.println("删除绣字颜色=="+xuzilist2.get(i).getCode()+"==="+plate_id+"=="+code6);
                        //根据品类id和编号查询当前没有删除的数据--仅仅只有一个
                        EmbroideredColorTestInfo zs_datadetail = againEnabledMapper.query_xiuziColortailByCode(xuzilist2.get(i).getCode(),category_id,2);
                        if(zs_datadetail!=null){
                            //执行添加
                            EmbroideredColorTestInfo datainfo = new EmbroideredColorTestInfo();
                            datainfo.setCode(zs_datadetail.getCode());
                            datainfo.setColorName(zs_datadetail.getColorName());
                            datainfo.setCategoryId(plate_id);
                            datainfo.setColorImg(zs_datadetail.getColorImg());
                            datainfo.setNumbers(zs_datadetail.getNumbers());
                            datainfo.setRemark(zs_datadetail.getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            datainfo.setStatus(0);
                            code6 = categoryInfoMapper.add_xiuzi_color(datainfo);
                        }
                    }else {
                        EmbroideredColorTestInfo xiuzidetail = againEnabledMapper.query_xiuziColortailByCode(xuzilist2.get(i).getCode(),plate_id,1);
                        if(xiuzidetail!=null){
                            System.out.println("修改绣字颜色=="+xuzilist2.get(i).getCode()+"==="+xiuzidetail.getId());
                            //执行修改
                            EmbroideredColorTestInfo datainfo = new EmbroideredColorTestInfo();
                            datainfo.setCode(xuzilist2.get(i).getCode());
                            datainfo.setColorName(xuzilist2.get(i).getColorName());
                            datainfo.setColorImg(xuzilist2.get(i).getColorImg());
                            datainfo.setNumbers(xuzilist2.get(i).getNumbers());
                            datainfo.setRemark(xuzilist2.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setUpdateBy(create_by);
                            datainfo.setId(xiuzidetail.getId());
                            code6 = categoryInfoMapper.update_xiuzi_color(datainfo);
                        }else {
                            System.out.println("增加绣字颜色=="+xuzilist2.get(i).getCode()+"==="+plate_id);
                            EmbroideredColorTestInfo datainfo = new EmbroideredColorTestInfo();
                            datainfo.setCode(xuzilist2.get(i).getCode());
                            datainfo.setColorName(xuzilist2.get(i).getColorName());
                            datainfo.setCategoryId(plate_id);
                            datainfo.setColorImg(xuzilist2.get(i).getColorImg());
                            datainfo.setNumbers(xuzilist2.get(i).getNumbers());
                            datainfo.setRemark(xuzilist2.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            datainfo.setStatus(0);
                            code6 = categoryInfoMapper.add_xiuzi_color(datainfo);
                        }
                    }
                }
        }
        if(xuzilist3.size()>0){
                for (int i = 0;i<xuzilist3.size();i++){
                    if(xuzilist3.get(i).getStatus() != 0){
                        //执行删除测试的数据-真删除
                        code7 = testPlateInfoMapper.delete_real_xiuzi_fontImg(plate_id,xuzilist3.get(i).getCode());
                        System.out.println("删除绣字字体或图片=="+xuzilist3.get(i).getCode()+"==="+plate_id);
                        //根据品类id和编号查询当前没有删除的数据--仅仅只有一个
                        EmbroideredFontTestInfo zs_datadetail = againEnabledMapper.query_xiuzifonttailByCode(xuzilist3.get(i).getCode(),category_id,2);
                        if(zs_datadetail!=null){
                            //执行添加
                            EmbroideredFontTestInfo datainfo = new EmbroideredFontTestInfo();
                            datainfo.setCode(zs_datadetail.getCode());
                            datainfo.setEmbroideredName(zs_datadetail.getEmbroideredName());
                            datainfo.setCategoryId(plate_id);
                            datainfo.setEmbroideredImage(zs_datadetail.getEmbroideredImage());
                            datainfo.setNumbers(zs_datadetail.getNumbers());
                            datainfo.setRemark(zs_datadetail.getRemark());
                            datainfo.setIsZitiImg(zs_datadetail.getIsZitiImg());
                            datainfo.setXiuziSize(zs_datadetail.getXiuziSize());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            datainfo.setStatus(0);
                            code7 = categoryInfoMapper.add_xiuzi_fontImg(datainfo);
                        }
                    }else {
                        EmbroideredFontTestInfo xiuzidetail = againEnabledMapper.query_xiuzifonttailByCode2(xuzilist3.get(i).getCode(),plate_id);
                        if(xiuzidetail != null){
                            System.out.println("修改绣字字体或图片=="+xuzilist3.get(i).getCode()+"==="+xiuzidetail.getId()+"=="+xuzilist3.get(i).getIsZitiImg());
                            //执行修改
                            EmbroideredFontTestInfo datainfo = new EmbroideredFontTestInfo();
                            datainfo.setCode(xuzilist3.get(i).getCode());
                            datainfo.setEmbroideredName(xuzilist3.get(i).getEmbroideredName());
                            datainfo.setEmbroideredImage(xuzilist3.get(i).getEmbroideredImage());
                            datainfo.setNumbers(xuzilist3.get(i).getNumbers());
                            datainfo.setRemark(xuzilist3.get(i).getRemark());
                            datainfo.setIsZitiImg(xuzilist3.get(i).getIsZitiImg());
                            datainfo.setXiuziSize(xuzilist3.get(i).getXiuziSize());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            datainfo.setStatus(0);
                            datainfo.setId(xiuzidetail.getId());
                            code7 = categoryInfoMapper.update_xiuzi_fontImg(datainfo);
                        }else{
                            System.out.println("增加绣字字体或图片=="+xuzilist3.get(i).getCode()+"==="+plate_id+"=="+xuzilist3.get(i).getIsZitiImg());
                            EmbroideredFontTestInfo datainfo = new EmbroideredFontTestInfo();
                            datainfo.setCode(xuzilist3.get(i).getCode());
                            datainfo.setEmbroideredName(xuzilist3.get(i).getEmbroideredName());
                            datainfo.setCategoryId(plate_id);
                            datainfo.setEmbroideredImage(xuzilist3.get(i).getEmbroideredImage());
                            datainfo.setNumbers(xuzilist3.get(i).getNumbers());
                            datainfo.setRemark(xuzilist3.get(i).getRemark());
                            datainfo.setIsZitiImg(xuzilist3.get(i).getIsZitiImg());
                            datainfo.setXiuziSize(xuzilist3.get(i).getXiuziSize());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            datainfo.setStatus(0);
                            code7 = categoryInfoMapper.add_xiuzi_fontImg(datainfo);
                        }
                    }
                }
        }

        /**
         * 身体尺寸模块
         * */
        if(bodysizelist2.size()>0){
            //在增加前执行删除
            code8 = againEnabledMapper.real_delete_bodysize(plate_id);
            for (int i = 0;i<bodysizelist2.size();i++){
                BodySizeTestInfo datainfo = new BodySizeTestInfo();
                datainfo.setBodySizename(bodysizelist2.get(i).getBodySizename());
                datainfo.setUnit(bodysizelist2.get(i).getUnit());
                datainfo.setModuleId(bodysizelist2.get(i).getModuleId());
                datainfo.setCategoryId(plate_id);
                datainfo.setNumbers(bodysizelist2.get(i).getNumbers());
                datainfo.setIsJin(bodysizelist2.get(i).getIsJin());
                datainfo.setMax(bodysizelist2.get(i).getMax());
                datainfo.setMin(bodysizelist2.get(i).getMin());
                datainfo.setIsBitian(bodysizelist2.get(i).getIsBitian());
                datainfo.setSysOrgCode(sys_org_code);
                datainfo.setCreateBy(create_by);
                code8 = categoryInfoMapper.add_testbodySize(datainfo);

//                    if(bodysizelist1.get(i).getStatus() != 0){
//                        //执行删除测试的数据-真删除
//                        code8 = testPlateInfoMapper.delete_real_size(plate_id,bodysizelist1.get(i).getBodySizename());
//                    }else {
//                        BodySizeTestInfo xiuzidetail = againEnabledMapper.query_bodysizetailByCode(bodysizelist1.get(i).getBodySizename(),plate_id);
//                        if(xiuzidetail != null){
//                            //执行修改
//                            BodySizeTestInfo datainfo = new BodySizeTestInfo();
//                            datainfo.setBodySizename(bodysizelist1.get(i).getBodySizename());
//                            datainfo.setUnit(bodysizelist1.get(i).getUnit());
//                            datainfo.setModuleId(bodysizelist1.get(i).getModuleId());
//                            datainfo.setNumbers(bodysizelist1.get(i).getNumbers());
//                            datainfo.setIsJin(bodysizelist1.get(i).getIsJin());
//                            datainfo.setMax(bodysizelist1.get(i).getMax());
//                            datainfo.setMin(bodysizelist1.get(i).getMin());
//                            datainfo.setIsBitian(bodysizelist1.get(i).getIsBitian());
//                            datainfo.setSysOrgCode(sys_org_code);
//                            datainfo.setUpdateBy(create_by);
//                            datainfo.setId(xiuzidetail.getId());
//                            code8 = categoryInfoMapper.update_testbodySize(datainfo);
//                        }else {
//                            BodySizeTestInfo datainfo = new BodySizeTestInfo();
//                            datainfo.setBodySizename(bodysizelist1.get(i).getBodySizename());
//                            datainfo.setUnit(bodysizelist1.get(i).getUnit());
//                            datainfo.setModuleId(bodysizelist1.get(i).getModuleId());
//                            datainfo.setCategoryId(plate_id);
//                            datainfo.setNumbers(bodysizelist1.get(i).getNumbers());
//                            datainfo.setIsJin(bodysizelist1.get(i).getIsJin());
//                            datainfo.setMax(bodysizelist1.get(i).getMax());
//                            datainfo.setMin(bodysizelist1.get(i).getMin());
//                            datainfo.setIsBitian(bodysizelist1.get(i).getIsBitian());
//                            datainfo.setSysOrgCode(sys_org_code);
//                            datainfo.setCreateBy(create_by);
//                            code8 = categoryInfoMapper.add_testbodySize(datainfo);
//                        }
//                    }
                }
            }
        /**
         * 返修模块
         * */
        if(fanxiulist.size()>0){
            for (int i = 0;i<fanxiulist.size();i++){
                    if(fanxiulist.get(i).getStatus() != 0){
                        //执行删除测试的数据-真删除
                        code9 = testPlateInfoMapper.delete_real_fanxiusize(plate_id,fanxiulist.get(i).getCode());
                        //根据品类id和编号查询当前没有删除的数据--仅仅只有一个
                        CategoryFanxiuTestInfo zs_datadetail = againEnabledMapper.query_fanxiubodysizetailByCode(fanxiulist.get(i).getCode(),category_id,2);
                        if(zs_datadetail!=null){
                            //执行添加
                            CategoryFanxiuTestInfo datainfo = new CategoryFanxiuTestInfo();
                            datainfo.setBodySizename(zs_datadetail.getBodySizename());
                            datainfo.setUnit(zs_datadetail.getUnit());
                            datainfo.setCategoryId(plate_id);
                            datainfo.setNumbers(zs_datadetail.getNumbers());
                            datainfo.setMax(zs_datadetail.getMax());
                            datainfo.setMin(zs_datadetail.getMin());
                            datainfo.setRemark(zs_datadetail.getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            datainfo.setCode(zs_datadetail.getCode());
                            code9 = categoryInfoMapper.add_testFanxiuSize(datainfo);
                        }
                    }else {
                        CategoryFanxiuTestInfo xiuzidetail = againEnabledMapper.query_fanxiubodysizetailByCode(fanxiulist.get(i).getCode(),plate_id,1);
                        if(xiuzidetail != null){
                            //执行修改
                            CategoryFanxiuTestInfo datainfo = new CategoryFanxiuTestInfo();
                            datainfo.setBodySizename(fanxiulist.get(i).getBodySizename());
                            datainfo.setUnit(fanxiulist.get(i).getUnit());
                            datainfo.setNumbers(fanxiulist.get(i).getNumbers());
                            datainfo.setMax(fanxiulist.get(i).getMax());
                            datainfo.setMin(fanxiulist.get(i).getMin());
                            datainfo.setRemark(fanxiulist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setUpdateBy(create_by);
                            datainfo.setId(xiuzidetail.getId());
                            code9 = categoryInfoMapper.update_testFanxiuSize(datainfo);
                        }else {
                            CategoryFanxiuTestInfo datainfo = new CategoryFanxiuTestInfo();
                            datainfo.setBodySizename(fanxiulist.get(i).getBodySizename());
                            datainfo.setUnit(fanxiulist.get(i).getUnit());
                            datainfo.setCategoryId(plate_id);
                            datainfo.setNumbers(fanxiulist.get(i).getNumbers());
                            datainfo.setMax(fanxiulist.get(i).getMax());
                            datainfo.setMin(fanxiulist.get(i).getMin());
                            datainfo.setRemark(fanxiulist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            datainfo.setCode(fanxiulist.get(i).getCode());
                            code9 = categoryInfoMapper.add_testFanxiuSize(datainfo);
                        }
                    }
                }
            }

        /**
         * 定制项模块
         * */
        if(dingzhilist.size()>0){
                for (int i = 0;i<dingzhilist.size();i++){
                    if(dingzhilist.get(i).getStatus() != 0){
                        //执行删除测试的数据-真删除
                        code1 = testPlateInfoMapper.delete_real_dingzhi(plate_id,dingzhilist.get(i).getCode());
                        //根据品类id和编号查询当前没有删除的数据--仅仅只有一个
                        SmalltemplateTestInfo zs_datadetail = againEnabledMapper.query_dingzhitailByCode(dingzhilist.get(i).getCode(),category_id,2);
                        if(zs_datadetail!=null){
                            //执行添加
                            SmalltemplateTestInfo datainfo = new SmalltemplateTestInfo();
                            datainfo.setModuleId(zs_datadetail.getModuleId());
                            datainfo.setCategoryId(plate_id);
                            datainfo.setCode(zs_datadetail.getCode());
                            datainfo.setParameter(zs_datadetail.getParameter());
                            datainfo.setImgs(zs_datadetail.getImgs());
                            datainfo.setNumbers(zs_datadetail.getNumbers());
                            datainfo.setIstype(zs_datadetail.getIstype());
                            datainfo.setRemark(zs_datadetail.getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code1 = categoryInfoMapper.add_dingzhi(datainfo);
                        }
                    }else {
                        SmalltemplateTestInfo datadetail = againEnabledMapper.query_dingzhitailByCode(dingzhilist.get(i).getCode(),plate_id,1);
                        if(datadetail != null){
                            //执行修改
                            SmalltemplateTestInfo datainfo = new SmalltemplateTestInfo();
                            datainfo.setParameter(dingzhilist.get(i).getParameter());
                            datainfo.setNumbers(dingzhilist.get(i).getNumbers());
                            datainfo.setRemark(dingzhilist.get(i).getRemark());
                            datainfo.setId(datadetail.getId());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setUpdateBy(create_by);
                            code1 = categoryInfoMapper.update_dingzhi(datainfo);
                        }else {
                            SmalltemplateTestInfo datainfo = new SmalltemplateTestInfo();
                            datainfo.setModuleId(dingzhilist.get(i).getModuleId());
                            datainfo.setCategoryId(plate_id);
                            datainfo.setCode(dingzhilist.get(i).getCode());
                            datainfo.setParameter(dingzhilist.get(i).getParameter());
                            datainfo.setImgs(dingzhilist.get(i).getImgs());
                            datainfo.setNumbers(dingzhilist.get(i).getNumbers());
                            datainfo.setIstype(dingzhilist.get(i).getIstype());
                            datainfo.setRemark(dingzhilist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code1 = categoryInfoMapper.add_dingzhi(datainfo);
                        }
                    }
                }
        }
        /**
         * 参数模块
         * */
        if(canshulist.size()>0){
                for (int i = 0;i<canshulist.size();i++){
                    if(canshulist.get(i).getStatus() != 0){
                        String praent_id1 = "";
                        SmalltemplateTestInfo ceshidingdatainfo = formalCategoryInfoMapper.query_dingzhiBydingzhId(canshulist.get(i).getParentId());
                        if (ceshidingdatainfo != null) {
                            //查询新增的定制项--测试版号
                            List<SmalltemplateTestInfo> zsdingzhi_datalist = testPlateInfoMapper.query_testdingzhiByBanhaoId(plate_id);
                            if (zsdingzhi_datalist.size() > 0) {
                                for (int j = 0; j < zsdingzhi_datalist.size(); j++) {
                                    if (ceshidingdatainfo.getCode().equals(zsdingzhi_datalist.get(j).getCode())) {
                                        praent_id1 = zsdingzhi_datalist.get(j).getId().toString();
                                    }
                                }
                            }
                        }
                        //执行删除测试的数据-真删除
                        code2 = testPlateInfoMapper.delete_real_dingzhi_canshu(plate_id,canshulist.get(i).getCategoryCode(),praent_id1);
                        //根据品类id和编号查询当前没有删除的数据--仅仅只有一个
                        MlccCategoryTestInfo zs_datadetail = againEnabledMapper.query_dingzhi_canshutailByCode(canshulist.get(i).getCategoryCode(),category_id,canshulist.get(i).getParentId(),2);
                        if(zs_datadetail!=null){
                            //执行添加
                            MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                            datainfo.setCategoryName(canshulist.get(i).getCategoryName());
                            datainfo.setCategoryCode(canshulist.get(i).getCategoryCode());
                            datainfo.setParentId(praent_id1);
                            datainfo.setImg(canshulist.get(i).getImg());
                            datainfo.setTopid(plate_id);
                            datainfo.setNumbers(canshulist.get(i).getNumbers());
                            datainfo.setIsType(canshulist.get(i).getIsType());
                            datainfo.setCost(canshulist.get(i).getCost());
                            datainfo.setTeamPrice2(canshulist.get(i).getTeamPrice2());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            datainfo.setStatus(0);
                            code2 = categoryInfoMapper.add_dingzhi_canshu(datainfo);
                        }

                    }else {
                        String praent_id = "";
                        SmalltemplateTestInfo ceshidingdatainfo = formalCategoryInfoMapper.query_dingzhiBydingzhId(canshulist.get(i).getParentId());
                        if (ceshidingdatainfo != null) {
                            //查询新增的定制项--测试版号
                            List<SmalltemplateTestInfo> zsdingzhi_datalist = testPlateInfoMapper.query_testdingzhiByBanhaoId(plate_id);
                            if (zsdingzhi_datalist.size() > 0) {
                                for (int j = 0; j < zsdingzhi_datalist.size(); j++) {
                                    if (ceshidingdatainfo.getCode().equals(zsdingzhi_datalist.get(j).getCode())) {
                                        praent_id = zsdingzhi_datalist.get(j).getId().toString();
                                    }
                                }
                            }
                        }
                        MlccCategoryTestInfo datadetail = againEnabledMapper.query_dingzhi_canshutailByCode(canshulist.get(i).getCategoryCode(),plate_id,praent_id,1);
                        if(datadetail != null){
                            //执行修改
                            MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                            datainfo.setCategoryName(canshulist.get(i).getCategoryName());
                            datainfo.setCategoryCode(canshulist.get(i).getCategoryCode());
                            datainfo.setImg(canshulist.get(i).getImg());
                            datainfo.setNumbers(canshulist.get(i).getNumbers());
                            datainfo.setIsType(0);
                            datainfo.setCost("0.00");
                            datainfo.setTeamPrice2("0.00");
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setUpdateBy(create_by);
                            datainfo.setId(datadetail.getId());
                            code2 = categoryInfoMapper.update_dingzhi_canshu(datainfo);
                        }else {
                            String praent_id2 = "";
                            SmalltemplateTestInfo ceshidingdatainfo2 = formalCategoryInfoMapper.query_dingzhiBydingzhId(canshulist.get(i).getParentId());
                            if (ceshidingdatainfo2 != null) {
                                //查询新增的定制项--测试版号
                                List<SmalltemplateTestInfo> zsdingzhi_datalist2 = testPlateInfoMapper.query_testdingzhiByBanhaoId(plate_id);
                                if (zsdingzhi_datalist2.size() > 0) {
                                    for (int j = 0; j < zsdingzhi_datalist2.size(); j++) {
                                        if (ceshidingdatainfo.getCode().equals(zsdingzhi_datalist2.get(j).getCode())) {
                                            praent_id2 = zsdingzhi_datalist2.get(j).getId().toString();
                                        }
                                    }
                                }
                            }
                            MlccCategoryTestInfo datainfo = new MlccCategoryTestInfo();
                            datainfo.setCategoryName(canshulist.get(i).getCategoryName());
                            datainfo.setCategoryCode(canshulist.get(i).getCategoryCode());
                            datainfo.setParentId(praent_id2);
                            datainfo.setImg(canshulist.get(i).getImg());
                            datainfo.setTopid(plate_id);
                            datainfo.setNumbers(canshulist.get(i).getNumbers());
                            datainfo.setIsType(canshulist.get(i).getIsType());
                            datainfo.setCost(canshulist.get(i).getCost());
                            datainfo.setTeamPrice2(canshulist.get(i).getTeamPrice2());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            datainfo.setStatus(0);
                            code2 = categoryInfoMapper.add_dingzhi_canshu(datainfo);
                        }
                    }
                }
            }
        /**
         * 撞色模块
         * */
        if(zhuangselist.size()>0){
                for (int i = 0;i<zhuangselist.size();i++){
                    if(zhuangselist.get(i).getStatus() != 0){
                        //执行删除测试的数据-真删除
                        code4 = testPlateInfoMapper.delete_real_zhuahngse(plate_id,zhuangselist.get(i).getCode());
                        //根据品类id和编号查询当前没有删除的数据--仅仅只有一个
                        ContrastcolorTestInfo zs_datadetail = againEnabledMapper.query_zhuangsetailByCode(zhuangselist.get(i).getCode(),category_id,2);
                        if(zs_datadetail!=null){
                            //执行添加
                            //查询新增的定制项
                            String dingzhi1 = "";
                            String firstId = "";
                            //根据品类id查询定制项
                            List<SmalltemplateTestInfo> zsdingzhi_datalist = categoryInfoMapper.query_dingzhiBycategoryId(plate_id);
                            SmalltemplateTestInfo ceshidingdatainfo1 = formalCategoryInfoMapper.query_dingzhiBydingzhId(zhuangselist.get(i).getDingzhiId());
                            if (ceshidingdatainfo1 != null) {
                                if (zsdingzhi_datalist.size() > 0) {
                                    for (int j = 0; j < zsdingzhi_datalist.size(); j++) {
                                        if (ceshidingdatainfo1.getCode().equals(zsdingzhi_datalist.get(j).getCode())) {
                                            dingzhi1 = zsdingzhi_datalist.get(j).getId().toString();
                                            break;
                                        }
                                    }
                                }
                            }
                            //根据类别id查询类别详情
                            MlccCategoryTestInfo leibiedatainfo1 = formalCategoryInfoMapper.select_testcategoryDetail(zhuangselist.get(i).getCategoryId());
                            if (leibiedatainfo1 != null) {
                                MlccCategoryInfo zsleibie = testPlateInfoMapper.select_zscategoryDetailByother(leibiedatainfo1.getCategoryCode(), plate_id, dingzhi1);
                                if (zsleibie != null) {
                                    firstId = zsleibie.getId().toString();
                                }
                            }
                            //执行修改
                            ContrastcolorTestInfo datainfo = new ContrastcolorTestInfo();
                            datainfo.setTopId(plate_id);
                            datainfo.setCode(zhuangselist.get(i).getCode());
                            datainfo.setContrastColorName(zhuangselist.get(i).getContrastColorName());
                            datainfo.setCategoryId(firstId);
                            datainfo.setContrastColorImg(zhuangselist.get(i).getContrastColorImg());
                            datainfo.setSinglePrice2(zhuangselist.get(i).getSinglePrice2());
                            datainfo.setTeamPrice2(zhuangselist.get(i).getTeamPrice2());
                            datainfo.setDingzhiId(dingzhi1);
                            datainfo.setRemark(zhuangselist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code4 = categoryInfoMapper.add_zhuangse(datainfo);
                        }
                    }else {
                        ContrastcolorTestInfo datadetail = againEnabledMapper.query_zhuangsetailByCode(zhuangselist.get(i).getCode(), plate_id,1);
                        if (datadetail != null) {
                            //查询新增的定制项
                            String dingzhi1 = "";
                            String firstId = "";
                            //根据品类id查询定制项
                            List<SmalltemplateTestInfo> zsdingzhi_datalist = categoryInfoMapper.query_dingzhiBycategoryId(plate_id);
                            SmalltemplateTestInfo ceshidingdatainfo1 = formalCategoryInfoMapper.query_dingzhiBydingzhId(zhuangselist.get(i).getDingzhiId());
                            if (ceshidingdatainfo1 != null) {
                                if (zsdingzhi_datalist.size() > 0) {
                                    for (int j = 0; j < zsdingzhi_datalist.size(); j++) {
                                        if (ceshidingdatainfo1.getCode().equals(zsdingzhi_datalist.get(j).getCode())) {
                                            dingzhi1 = zsdingzhi_datalist.get(j).getId().toString();
                                            break;
                                        }
                                    }
                                }
                            }
                            //根据类别id查询类别详情
                            MlccCategoryTestInfo leibiedatainfo1 = formalCategoryInfoMapper.select_testcategoryDetail(zhuangselist.get(i).getCategoryId());
                            if (leibiedatainfo1 != null) {
                                MlccCategoryInfo zsleibie = testPlateInfoMapper.select_zscategoryDetailByother(leibiedatainfo1.getCategoryCode(), plate_id, dingzhi1);
                                if (zsleibie != null) {
                                    firstId = zsleibie.getId().toString();
                                }
                            }
                            //执行修改
                            ContrastcolorTestInfo datainfo = new ContrastcolorTestInfo();
                            datainfo.setTopId(plate_id);
                            datainfo.setCode(zhuangselist.get(i).getCode());
                            datainfo.setContrastColorName(zhuangselist.get(i).getContrastColorName());
                            datainfo.setCategoryId(firstId);
                            datainfo.setContrastColorImg(zhuangselist.get(i).getContrastColorImg());
                            datainfo.setSinglePrice2(zhuangselist.get(i).getSinglePrice2());
                            datainfo.setTeamPrice2(zhuangselist.get(i).getTeamPrice2());
                            datainfo.setDingzhiId(dingzhi1);
                            datainfo.setRemark(zhuangselist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            datainfo.setId(datadetail.getId());
                            code4 = categoryInfoMapper.update_zhuangse(datainfo);
                        } else {
                            //查询新增的定制项
                            String dingzhi1 = "";
                            String firstId = "";
                            //根据品类id查询定制项
                            List<SmalltemplateTestInfo> zsdingzhi_datalist = categoryInfoMapper.query_dingzhiBycategoryId(plate_id);
                            SmalltemplateTestInfo ceshidingdatainfo1 = formalCategoryInfoMapper.query_dingzhiBydingzhId(zhuangselist.get(i).getDingzhiId());
                            if (ceshidingdatainfo1 != null) {
                                if (zsdingzhi_datalist.size() > 0) {
                                    for (int j = 0; j < zsdingzhi_datalist.size(); j++) {
                                        if (ceshidingdatainfo1.getCode().equals(zsdingzhi_datalist.get(j).getCode())) {
                                            dingzhi1 = zsdingzhi_datalist.get(j).getId().toString();
                                            break;
                                        }
                                    }
                                }
                            }
                            //根据类别id查询类别详情
                            MlccCategoryTestInfo leibiedatainfo1 = formalCategoryInfoMapper.select_testcategoryDetail(zhuangselist.get(i).getCategoryId());
                            if (leibiedatainfo1 != null) {
                                MlccCategoryInfo zsleibie = testPlateInfoMapper.select_zscategoryDetailByother(leibiedatainfo1.getCategoryCode(), plate_id, dingzhi1);
                                if (zsleibie != null) {
                                    firstId = zsleibie.getId().toString();
                                }
                            }
                            //执行修改
                            ContrastcolorTestInfo datainfo = new ContrastcolorTestInfo();
                            datainfo.setTopId(plate_id);
                            datainfo.setCode(zhuangselist.get(i).getCode());
                            datainfo.setContrastColorName(zhuangselist.get(i).getContrastColorName());
                            datainfo.setCategoryId(firstId);
                            datainfo.setContrastColorImg(zhuangselist.get(i).getContrastColorImg());
                            datainfo.setSinglePrice2(zhuangselist.get(i).getSinglePrice2());
                            datainfo.setTeamPrice2(zhuangselist.get(i).getTeamPrice2());
                            datainfo.setDingzhiId(dingzhi1);
                            datainfo.setRemark(zhuangselist.get(i).getRemark());
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code4 = categoryInfoMapper.add_zhuangse(datainfo);
                        }
                    }
                }
        }

        /**
         * 互斥项模块
         * */
        if(huchilist.size()>0){
                for (int i = 0;i<huchilist.size();i++){
                    if(huchilist.get(i).getStatus() == 3){
                        //执行删除测试的数据-真删除
                        code3 = testPlateInfoMapper.delete_real_huchi(plate_id,huchilist.get(i).getCode());
                        //根据品类id和编号查询当前没有删除的数据--仅仅只有一个
                        MutexTestInfo zs_datadetail = againEnabledMapper.query_huchitailByCode(huchilist.get(i).getCode(),category_id,2);
                        if(zs_datadetail!=null){
                            //执行添加
                            //查询新增的定制项
                            String dingzhi1="",dingzhi2="";
                            String firstId = "",secoundId="";
                            //根据品类id查询定制项
                            List<SmalltemplateTestInfo> zsdingzhi_datalist = categoryInfoMapper.query_dingzhiBycategoryId(plate_id);

                            SmalltemplateTestInfo ceshidingdatainfo1 = formalCategoryInfoMapper.query_dingzhiBydingzhId(huchilist.get(i).getDingzhi1());
                            SmalltemplateTestInfo ceshidingdatainfo2 = formalCategoryInfoMapper.query_dingzhiBydingzhId(huchilist.get(i).getDingzhi2());
                            if(ceshidingdatainfo1!=null){
                                if(zsdingzhi_datalist.size()>0){
                                    for (int j=0;j<zsdingzhi_datalist.size();j++){
                                        if(ceshidingdatainfo1.getCode().equals(zsdingzhi_datalist.get(j).getCode())){
                                            dingzhi1 = zsdingzhi_datalist.get(j).getId().toString();
                                            break;
                                        }
                                    }
                                }
                            }
                            if(ceshidingdatainfo2!=null){
                                if(zsdingzhi_datalist.size()>0){
                                    for (int f=0;f<zsdingzhi_datalist.size();f++){
                                        if(ceshidingdatainfo2.getCode().equals(zsdingzhi_datalist.get(f).getCode())){
                                            dingzhi2 = zsdingzhi_datalist.get(f).getId().toString();
                                            break;
                                        }
                                    }
                                }
                            }
                            //根据类别id查询类别详情
                            MlccCategoryTestInfo leibiedatainfo1 = formalCategoryInfoMapper.select_testcategoryDetail(huchilist.get(i).getCategoryId());
                            if(leibiedatainfo1!=null){
                                MlccCategoryInfo zsleibie = testPlateInfoMapper.select_zscategoryDetailByother(leibiedatainfo1.getCategoryCode(),plate_id,dingzhi1);
                                if(zsleibie!=null){
                                    firstId = zsleibie.getId().toString();
                                }
                            }
                            String canshuids[] = huchilist.get(i).getCategoryOther().split(",");
                            System.out.println("其他参数=="+huchilist.get(i).getCategoryOther()+"=="+dingzhi2);
                            String strbody="";
                            for (String s:canshuids){
                                //根据类别id查询类别详情
                                MlccCategoryTestInfo leibiedatainfo2 = formalCategoryInfoMapper.select_testcategoryDetail(s);
                                if(leibiedatainfo2!=null){
                                    MlccCategoryInfo zsleibie = testPlateInfoMapper.select_zscategoryDetailByother(leibiedatainfo2.getCategoryCode(),plate_id,dingzhi2);
                                    if(zsleibie!=null){
                                        strbody += zsleibie.getId().toString()+",";
                                    }
                                }
                            }
                            if(strbody==null || "".equals(strbody)){
                                secoundId = "";
                            }else {
                                secoundId = strbody.substring(0,strbody.length()-1);
                            }
                            //执行修改
                            MutexTestInfo datainfo = new MutexTestInfo();
                            datainfo.setMutexName(huchilist.get(i).getMutexName());
                            datainfo.setTopId(plate_id);
                            datainfo.setCategoryId(firstId);
                            datainfo.setCategoryOther(secoundId);
                            datainfo.setMutexReason(huchilist.get(i).getMutexReason());
                            datainfo.setStatus(huchilist.get(i).getStatus());
                            datainfo.setCode(huchilist.get(i).getCode());
                            datainfo.setDingzhi1(dingzhi1);
                            datainfo.setDingzhi2(dingzhi2);
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code3 = categoryInfoMapper.add_huchi(datainfo);
                        }
                    }else {
                        MutexTestInfo datadetail = againEnabledMapper.query_huchitailByCode(huchilist.get(i).getCode(), plate_id,1);
                        if (datadetail != null) {
                            //查询新增的定制项
                            String dingzhi1="",dingzhi2="";
                            String firstId = "",secoundId="";
                            //根据品类id查询定制项
                            List<SmalltemplateTestInfo> zsdingzhi_datalist = categoryInfoMapper.query_dingzhiBycategoryId(plate_id);
                            SmalltemplateTestInfo ceshidingdatainfo1 = formalCategoryInfoMapper.query_dingzhiBydingzhId(huchilist.get(i).getDingzhi1());
                            SmalltemplateTestInfo ceshidingdatainfo2 = formalCategoryInfoMapper.query_dingzhiBydingzhId(huchilist.get(i).getDingzhi2());
                            if(ceshidingdatainfo1!=null){
                                if(zsdingzhi_datalist.size()>0){
                                    for (int j=0;j<zsdingzhi_datalist.size();j++){
                                        if(ceshidingdatainfo1.getCode().equals(zsdingzhi_datalist.get(j).getCode())){
                                            dingzhi1 = zsdingzhi_datalist.get(j).getId().toString();
                                            break;
                                        }
                                    }
                                }
                            }
                            if(ceshidingdatainfo2!=null){
                                if(zsdingzhi_datalist.size()>0){
                                    for (int f=0;f<zsdingzhi_datalist.size();f++){
                                        if(ceshidingdatainfo2.getCode().equals(zsdingzhi_datalist.get(f).getCode())){
                                            dingzhi2 = zsdingzhi_datalist.get(f).getId().toString();
                                            break;
                                        }
                                    }
                                }
                            }
                            //根据类别id查询类别详情
                            MlccCategoryTestInfo leibiedatainfo1 = formalCategoryInfoMapper.select_testcategoryDetail(huchilist.get(i).getCategoryId());
                            if(leibiedatainfo1!=null){
                                MlccCategoryInfo zsleibie = testPlateInfoMapper.select_zscategoryDetailByother(leibiedatainfo1.getCategoryCode(),plate_id,dingzhi1);
                                if(zsleibie!=null){
                                    firstId = zsleibie.getId().toString();
                                }
                            }
                            String canshuids[] = huchilist.get(i).getCategoryOther().split(",");
                            String strbody="";
                            for (String s:canshuids){
                                //根据类别id查询类别详情
                                MlccCategoryTestInfo leibiedatainfo2 = formalCategoryInfoMapper.select_testcategoryDetail(s);
                                if(leibiedatainfo2!=null){
                                    MlccCategoryInfo zsleibie = testPlateInfoMapper.select_zscategoryDetailByother(leibiedatainfo2.getCategoryCode(),plate_id,dingzhi2);
                                    if(zsleibie!=null){
                                        strbody += zsleibie.getId().toString()+",";
                                    }
                                }
                            }
                            if(strbody==null || "".equals(strbody)){
                                secoundId = "";
                            }else {
                                secoundId = strbody.substring(0,strbody.length()-1);
                            }

                            //执行修改
                            MutexTestInfo datainfo = new MutexTestInfo();
                            datainfo.setMutexName(huchilist.get(i).getMutexName());
                            datainfo.setTopId(plate_id);
                            datainfo.setCategoryId(firstId);
                            datainfo.setCategoryOther(secoundId);
                            datainfo.setMutexReason(huchilist.get(i).getMutexReason());
                            datainfo.setStatus(huchilist.get(i).getStatus());
                            datainfo.setCode(huchilist.get(i).getCode());
                            datainfo.setDingzhi1(dingzhi1);
                            datainfo.setDingzhi2(dingzhi2);
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            datainfo.setId(datadetail.getId());
                            code3 = categoryInfoMapper.update_huchi(datainfo);
                        }else {
                            //查询新增的定制项
                            String dingzhi1="",dingzhi2="";
                            String firstId = "",secoundId="";
                            //根据品类id查询定制项
                            List<SmalltemplateTestInfo> zsdingzhi_datalist = categoryInfoMapper.query_dingzhiBycategoryId(plate_id);

                            SmalltemplateTestInfo ceshidingdatainfo1 = formalCategoryInfoMapper.query_dingzhiBydingzhId(huchilist.get(i).getDingzhi1());
                            SmalltemplateTestInfo ceshidingdatainfo2 = formalCategoryInfoMapper.query_dingzhiBydingzhId(huchilist.get(i).getDingzhi2());
                            if(ceshidingdatainfo1!=null){
                                if(zsdingzhi_datalist.size()>0){
                                    for (int j=0;j<zsdingzhi_datalist.size();j++){
                                        if(ceshidingdatainfo1.getCode().equals(zsdingzhi_datalist.get(j).getCode())){
                                            dingzhi1 = zsdingzhi_datalist.get(j).getId().toString();
                                            break;
                                        }
                                    }
                                }
                            }
                            if(ceshidingdatainfo2!=null){
                                if(zsdingzhi_datalist.size()>0){
                                    for (int f=0;f<zsdingzhi_datalist.size();f++){
                                        if(ceshidingdatainfo2.getCode().equals(zsdingzhi_datalist.get(f).getCode())){
                                            dingzhi2 = zsdingzhi_datalist.get(f).getId().toString();
                                            break;
                                        }
                                    }
                                }
                            }
                            //根据类别id查询类别详情
                            MlccCategoryTestInfo leibiedatainfo1 = formalCategoryInfoMapper.select_testcategoryDetail(huchilist.get(i).getCategoryId());
                            if(leibiedatainfo1!=null){
                                MlccCategoryInfo zsleibie = testPlateInfoMapper.select_zscategoryDetailByother(leibiedatainfo1.getCategoryCode(),plate_id,dingzhi1);
                                if(zsleibie!=null){
                                    firstId = zsleibie.getId().toString();
                                }
                            }
                            String canshuids[] = huchilist.get(i).getCategoryOther().split(",");
                            System.out.println("其他参数=="+huchilist.get(i).getCategoryOther()+"=="+dingzhi2);
                            String strbody="";
                            for (String s:canshuids){
                                //根据类别id查询类别详情
                                MlccCategoryTestInfo leibiedatainfo2 = formalCategoryInfoMapper.select_testcategoryDetail(s);
                                if(leibiedatainfo2!=null){
                                    MlccCategoryInfo zsleibie = testPlateInfoMapper.select_zscategoryDetailByother(leibiedatainfo2.getCategoryCode(),plate_id,dingzhi2);
                                    if(zsleibie!=null){
                                        strbody += zsleibie.getId().toString()+",";
                                    }
                                }
                            }
                            if(strbody==null || "".equals(strbody)){
                                secoundId = "";
                            }else {
                                secoundId = strbody.substring(0,strbody.length()-1);
                            }
                            //执行修改
                            MutexTestInfo datainfo = new MutexTestInfo();
                            datainfo.setMutexName(huchilist.get(i).getMutexName());
                            datainfo.setTopId(plate_id);
                            datainfo.setCategoryId(firstId);
                            datainfo.setCategoryOther(secoundId);
                            datainfo.setMutexReason(huchilist.get(i).getMutexReason());
                            datainfo.setStatus(huchilist.get(i).getStatus());
                            datainfo.setCode(huchilist.get(i).getCode());
                            datainfo.setDingzhi1(dingzhi1);
                            datainfo.setDingzhi2(dingzhi2);
                            datainfo.setSysOrgCode(sys_org_code);
                            datainfo.setCreateBy(create_by);
                            code3 = categoryInfoMapper.add_huchi(datainfo);
                        }
                    }
                }
        }
        Long end_time = System.currentTimeMillis();
        System.out.println("最终同步数据输出时间："+(end_time-start_time));
        System.out.println("各个code=="+code1+"=="+ code2 + "=" + code3 + "=" + code4 + "=" + code5 + "=" + code6 + "=" + code7 + "=" + code8 + "=" + code9 + "=" + code10);
        if (code1 > 0 || code2 > 0 || code3 > 0 || code4 > 0 || code5 > 0 || code6 > 0 || code7 > 0 || code8 > 0 || code9 > 0 || code10 > 0) {
            //测试区
            formalCategoryInfoMapper.add_qiyong_record(plate_id,"1","2","数据同步成功",create_by,sys_org_code);
            return 0;
        } else {
            return 1;
        }
    }
}
